@camstack/addon-admin-ui 1.2.501 → 1.2.502
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assets/{AddonAssetIcon-B_mf6RWm.js → AddonAssetIcon-BE4IRtcr.js} +1 -1
- package/dist/assets/Addons-BpGMIVwu.js +5 -0
- package/dist/assets/{AdminPage-CV0QlJ3B.js → AdminPage-DO4TvyzZ.js} +1 -1
- package/dist/assets/{AdminSectionedPage-BBzHFRdX.js → AdminSectionedPage-DbSVTTH0.js} +1 -1
- package/dist/assets/AiProfiles-DlLpJu6R.js +3 -0
- package/dist/assets/{BrokerEditorDialog-B0caFBKZ.js → BrokerEditorDialog-ZqEB1OeF.js} +1 -1
- package/dist/assets/Build-D-kordXj.js +40 -0
- package/dist/assets/{Calendars-DUeEHzYQ.js → Calendars-CPKyT4jY.js} +1 -1
- package/dist/assets/{Cluster-C94n--nx.js → Cluster-2uEFOeHM.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-ym4ZV8sX.js → CompositionBlockEditor-Ch4cyhPp.js} +1 -1
- package/dist/assets/{CompositionEditorPage-BJvn56ZF.js → CompositionEditorPage-mWPEX9E1.js} +1 -1
- package/dist/assets/Data-DHfi_Lpj.js +2 -0
- package/dist/assets/DeviceDetail-Dj663lX6.js +2 -0
- package/dist/assets/{DeviceDoActionFields-cDGcUl-R.js → DeviceDoActionFields-BjxeF1AZ.js} +1 -1
- package/dist/assets/{Devices-CMNofKy8.js → Devices-BIokWQGH.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BVOyRHsA.js → EmbedPlayerPage-BAopgKNa.js} +1 -1
- package/dist/assets/HelperWizard-BVEjPQvM.js +2 -0
- package/dist/assets/History-DJR_LsxX.js +1 -0
- package/dist/assets/Identity-Do-Unn14.js +1 -0
- package/dist/assets/IntegrationDetail-Dbw98oyP.js +1 -0
- package/dist/assets/IntegrationHub-cywGK2Wp.js +1 -0
- package/dist/assets/Integrations-C0ckAtmU.js +1 -0
- package/dist/assets/{Integrations-DCLPgkRU.js → Integrations-DeVdSE8D.js} +1 -1
- package/dist/assets/{Library-CywHGHiE.js → Library-DCcWEFFl.js} +1 -1
- package/dist/assets/Locations-CYrSAzVs.js +3 -0
- package/dist/assets/{Logs-CNNOSCVp.js → Logs-CfwzwwGK.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-95iTn7i0.js → MaskShapeCanvas-DtFd99MF.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CaCqDalH.js → MotionZonesSettings-CQl2EA6N.js} +1 -1
- package/dist/assets/{MyAccess-C3uzlk10.js → MyAccess-DD7nAn5h.js} +1 -1
- package/dist/assets/Network-BYuL-L4z.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-BfighMS8.js → NodeAddonsSettingsPanel-D3T2zuD1.js} +1 -1
- package/dist/assets/Notifications-CzX3nzZP.js +1 -0
- package/dist/assets/Pipeline-Bq6O6mrO.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-CRWyEMXU.js → PrivacyMaskSettings-qYOg-1SO.js} +1 -1
- package/dist/assets/Recordings-NipGCr6f.js +1 -0
- package/dist/assets/{ScanNetworkModal-wDrkbkgj.js → ScanNetworkModal-CWiM9HWV.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-BVY8z5nP.js → SceneMonitorEditor-Ba9gLNWL.js} +1 -1
- package/dist/assets/SessionsList-DWm1_JRD.js +2 -0
- package/dist/assets/{Showroom-B7W2AkOm.js → Showroom-ChlaT6Cm.js} +1 -1
- package/dist/assets/System-Cby1MNlk.js +1 -0
- package/dist/assets/{Terminal-DD8pjpg-.js → Terminal-BrONi7mZ.js} +3 -3
- package/dist/assets/{Viewer-gI0qsTA2.js → Viewer-C5qA4uKO.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CRywONZ3.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BTGIQmuA.js} +1 -1
- package/dist/assets/{addon-icons-context-Cti7cTZ4.js → addon-icons-context-BZhSRQ2k.js} +1 -1
- package/dist/assets/{archive-PRZmhl9-.js → archive-BJkTmC56.js} +1 -1
- package/dist/assets/{assignment-candidates-BgsEkAFx.js → assignment-candidates-DJLitZnD.js} +1 -1
- package/dist/assets/{authed-media-HL5k5ZI9.js → authed-media-BC_02usb.js} +1 -1
- package/dist/assets/{bell-off-Wp9nXhK0.js → bell-off-DMGqFkTx.js} +1 -1
- package/dist/assets/{board-model-C9x5MlfE.js → board-model-CCAK2YmC.js} +1 -1
- package/dist/assets/{boxes-EVKxMyl3.js → boxes-Bajlyp9F.js} +1 -1
- package/dist/assets/circle-slash-Dng6-XsF.js +1 -0
- package/dist/assets/{client-Rf8T-Qxy.js → client-BqE1zM9p.js} +34 -34
- package/dist/assets/{cloud-upload-D1rJHyyL.js → cloud-upload-BXAu0WA_.js} +1 -1
- package/dist/assets/crop-CLBowvwG.js +1 -0
- package/dist/assets/{device-integration-icon-BN3tz8Fb.js → device-integration-icon-DLda0bDE.js} +1 -1
- package/dist/assets/device-picker-model-CHicgClc.js +1 -0
- package/dist/assets/{dist-BtSMcY1H.js → dist-B3iqcRcx.js} +1 -1
- package/dist/assets/{eraser-yP8-Qrpb.js → eraser-BP7I6n2j.js} +1 -1
- package/dist/assets/{format-B2NBW7cS.js → format-XZs_xh1r.js} +1 -1
- package/dist/assets/{hard-drive-download-DR6ciRuk.js → hard-drive-download-bSbR-kqh.js} +1 -1
- package/dist/assets/{hostInit-DSbl59EP.js → hostInit-CqBL2ZCP.js} +1 -1
- package/dist/assets/i18n-uD14huY2.js +1 -0
- package/dist/assets/icons-C3RUxRxL.js +1 -0
- package/dist/assets/{index-DUGfFMf0.js → index-BGJbArko.js} +3 -3
- package/dist/assets/index-WAVCQxxk.css +2 -0
- package/dist/assets/{key-DtVIVyHw.js → key-D2U0s0LY.js} +1 -1
- package/dist/assets/{key-round-_CfxOK2a.js → key-round-D8xR5lTT.js} +1 -1
- package/dist/assets/{layers-DhmA7JNn.js → layers-sqZU1Efj.js} +1 -1
- package/dist/assets/{linked-devices-model-CwgRN3Vm.js → linked-devices-model-DQCmeWmy.js} +1 -1
- package/dist/assets/{list-ordered-Bj8Zr-Wv.js → list-ordered-BGulzxMx.js} +1 -1
- package/dist/assets/{location-owned-usage-CFSvary3.js → location-owned-usage-CLPPrh2c.js} +1 -1
- package/dist/assets/{log-in-l36ik9Wr.js → log-in-D88bsbT9.js} +1 -1
- package/dist/assets/{memory-stick-DbUkE9Fa.js → memory-stick-DuklOVmZ.js} +1 -1
- package/dist/assets/{message-square-plus-jm9v9hN-.js → message-square-plus-CrWXPaYo.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ac5e508a.js → mf-entry-bootstrap-0-d28584aa.js} +2 -2
- package/dist/assets/{mic-off-BjaY8dq2.js → mic-off-LpAoBdO7.js} +1 -1
- package/dist/assets/{monitor-off-T1bFmYrx.js → monitor-off-BaVOrPeY.js} +1 -1
- package/dist/assets/{monitor-smartphone-DMpXo7Ar.js → monitor-smartphone-COSQV55Z.js} +1 -1
- package/dist/assets/mount-CHicgClc.js +1 -0
- package/dist/assets/{player-overlays-BFb5SWA9.js → player-overlays-DDvKn1W0.js} +1 -1
- package/dist/assets/{recycle-CRzk0gFj.js → recycle-CD8ymUv3.js} +1 -1
- package/dist/assets/remoteEntry-Br1rMgc-.js +1 -0
- package/dist/assets/{scan-eye-DkFdWjWi.js → scan-eye-CdfmPhrl.js} +1 -1
- package/dist/assets/{scissors-V4FufEMU.js → scissors-Bl3fg6Ss.js} +1 -1
- package/dist/assets/{search-x-DXTPMB2A.js → search-x-CZruDJ75.js} +1 -1
- package/dist/assets/{send-D-vjMUJY.js → send-Cdk8pNT7.js} +1 -1
- package/dist/assets/{settings-2-DUxYPsEJ.js → settings-2-DqKxa0Hf.js} +1 -1
- package/dist/assets/{sigma-D8LyGcav.js → sigma-ByejGGJ9.js} +1 -1
- package/dist/assets/{speaker-CKpoIyB7.js → speaker-B-TcfLx7.js} +1 -1
- package/dist/assets/src-TayryneI.js +67 -0
- package/dist/assets/{step-inspector-model-DNorKN85.js → step-inspector-model-B6yVCl09.js} +1 -1
- package/dist/assets/{table-2-uZMmLo6a.js → table-2-C753-50s.js} +1 -1
- package/dist/assets/{timer-reset-BWav2Kmp.js → timer-reset-CF7cF_Ga.js} +1 -1
- package/dist/assets/{unlink-Dse438EC.js → unlink-C3Qb_GTc.js} +1 -1
- package/dist/assets/{usb-SlY_Gb57.js → usb-CTHiJtrH.js} +1 -1
- package/dist/assets/{use-scenes-feed-Cz0AwuYh.js → use-scenes-feed-onSFrxVP.js} +1 -1
- package/dist/assets/{use-stationary-objects-B67ttHhM.js → use-stationary-objects-CpKg50zN.js} +1 -1
- package/dist/assets/useEventInvalidation-CHicgClc.js +1 -0
- package/dist/assets/{useNodeUrlSelection-Bxfo2t0-.js → useNodeUrlSelection-B-S1kSBF.js} +1 -1
- package/dist/assets/user-round-D_ZjF5gh.js +1 -0
- package/dist/assets/{user-x-BrW6KRXD.js → user-x-BaEc4WgN.js} +1 -1
- package/dist/assets/{ungroup-BhcUGbr2.js → variable-b7iNWVN7.js} +1 -1
- package/dist/assets/{video-B6REUv1P.js → video-CF2QZpF3.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DT2p44li.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B0_zurpm.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Addons-Cb6acpoY.js +0 -5
- package/dist/assets/AiProfiles-8TF3xjgg.js +0 -3
- package/dist/assets/Build-Xnlo6o_D.js +0 -40
- package/dist/assets/Data-DlzonlmW.js +0 -2
- package/dist/assets/DeviceDetail-DyLsUAqL.js +0 -2
- package/dist/assets/HelperWizard-C88ULCYq.js +0 -2
- package/dist/assets/History-t_uoaPpG.js +0 -1
- package/dist/assets/Identity-DiBBudOW.js +0 -1
- package/dist/assets/IntegrationDetail-B8gBda81.js +0 -1
- package/dist/assets/IntegrationHub-GrzjNslW.js +0 -1
- package/dist/assets/Integrations-D6KthXEF.js +0 -1
- package/dist/assets/Locations-BjRSPp5J.js +0 -3
- package/dist/assets/Network-CZ4xHzLW.js +0 -1
- package/dist/assets/Notifications-BdmCmJ2W.js +0 -1
- package/dist/assets/Pipeline-DG-vcE0_.js +0 -1
- package/dist/assets/Recordings-BpwE9JN_.js +0 -1
- package/dist/assets/SessionsList-DI5IhzU9.js +0 -2
- package/dist/assets/System-Cpe7wkVv.js +0 -1
- package/dist/assets/circle-slash-xh1tUz_M.js +0 -1
- package/dist/assets/crop-6qnHQHCf.js +0 -1
- package/dist/assets/device-picker-model-DL02cGAU.js +0 -1
- package/dist/assets/i18n-BDPAB47Q.js +0 -1
- package/dist/assets/icons-CvkjwiJn.js +0 -1
- package/dist/assets/index-BPZW59_u.css +0 -2
- package/dist/assets/mount-DL02cGAU.js +0 -1
- package/dist/assets/remoteEntry-DIlhbTG-.js +0 -1
- package/dist/assets/src-BfkcE2yV.js +0 -67
- package/dist/assets/useEventInvalidation-DL02cGAU.js +0 -1
- package/dist/assets/user-round-C4iC5VEd.js +0 -1
|
@@ -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{Di as l,En as u,Fn as d,Gr as f,Ht as p,Oi as m,Ti as h,Wr as g,bt as _,dt as v,fr as y,gn as b,gt as x,kn as S,na as C,pa as ee,pi as w,wn as T,yi as E,yn as D,zt as O}from"./player-overlays-BFb5SWA9.js";import{oa as k}from"./client-Rf8T-Qxy.js";import{t as A}from"./search-x-DXTPMB2A.js";import{$a as te,At as j,Do as M,Hn as ne,Mt as N,Qa as P,Tn as F,To as I,Tr as L,Wn as R,Wo as z,Xa as B,Ya as V,Yr as H,Za as U,_a as W,_o as G,_r as K,ad as q,ar as J,bd as re,co as ie,dr as ae,ds as oe,en as se,fi as ce,fo as le,fr as ue,fs as de,gd as fe,gr as pe,gs as Y,ha as X,hn as me,hr as he,hs as ge,io as _e,ji as ve,kt as ye,lo as be,ms as xe,pa as Se,pi as Ce,pr as we,ps as Te,ro as Ee,to as De,vs as Oe}from"./src-BfkcE2yV.js";import{t as Z}from"./useTranslation-BJr-n0es.js";import{n as ke}from"./addon-icons-context-Cti7cTZ4.js";import{P as Ae,gr as je,hr as Me,mr as Ne,ur as Pe}from"./index-DUGfFMf0.js";import{t as Fe}from"./device-integration-icon-BN3tz8Fb.js";import{a as Ie,i as Le,r as Re,t as ze}from"./ScanNetworkModal-wDrkbkgj.js";import{t as Be}from"./NodeAddonsSettingsPanel-BfighMS8.js";s();function Ve(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Ve(n.fields));return t}function Q(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...Ve(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 He(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(...He(n.fields));return t}function Ue(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 We(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Ge({open:t,integrationId:s,addonId:u,onClose:d}){let{t:f}=Z(),p=c(),[m,h]=o({}),[g,v]=o(!1),[b,S]=o(null),[C,ee]=o(We),w=I({addonId:u},{enabled:t}),T=w.data?.deviceType??null,E=le({addonId:u,type:T??k.Camera},{enabled:t&&w.isSuccess&&T!==null}),A=E.data??null;a(()=>{t&&(h(A?$(A.sections.flatMap(e=>e.fields)):{}),ee(We()),v(!1),S(null))},[t,s,A]);let te=n(()=>({...m,_probeRequestId:C}),[m,C]),j=Ee({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),M=z(),ne=r(async(e,t)=>{v(!0);let n=await M.mutateAsync({addonId:u,type:T??k.Camera,key:e,value:t,formValues:te});return n.status===`ok`&&n.suggestedValues&&h(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))Ue(e[i])&&!Ue(a)&&(r[i]=a,t=!0);return t?r:e}),n},[M,u,te,T]),{testAllStatus:N,hasProbeFields:P,probeResults:F,handleTestAll:L,clearProbeResult:R}=Q(A??{sections:[]},m,ne);async function B(e){S(null);try{await j.mutateAsync({addonId:u,type:T??k.Camera,config:m,integrationId:s}),e?h(A?$(A.sections.flatMap(e=>e.fields)):{}):d()}catch(e){S(e instanceof Error?e.message:String(e))}}if(!t)return null;let V=He((A?.sections??[]).flatMap(e=>e.fields)).filter(e=>Ue(m[e])),H=V.length===0,U=w.isLoading||T!==null&&E.isLoading,W=w.isError||w.isSuccess&&T===null||E.isError||E.isSuccess&&A===null;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:d}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.addDevice`)}),i(`button`,{onClick:d,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(x,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:U?i(`div`,{className:`flex items-center justify-center py-8`,children:i(y,{className:`h-5 w-5 animate-spin text-primary`})}):W?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:f(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Pe,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:u},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ae,{schema:A,values:m,onChange:h,onTestField:ne,probeResults:F,onClearProbe:R})}),!W&&!U&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between px-5 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`}),f(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:C.slice(0,14)})]}),i(l,{className:`h-3.5 w-3.5 transition-transform ${g?`rotate-180`:``}`})]}),g&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(se,{addonId:u,requestId:C,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!W&&!U&&(b||V.length>0)&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 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:b||f(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:V.join(`, `)})})]})}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`)}),!W&&P&&e(`button`,{type:`button`,onClick:L,disabled:N===`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:[N===`testing`?i(y,{className:`h-3.5 w-3.5 animate-spin`}):i(_,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>B(!0),disabled:W||!H||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:f(`integrations.saveAndNew`)}),i(`button`,{onClick:()=>B(!1),disabled:W||!H||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?f(`integrations.saving`):f(`integrations.save`)})]})]})]})]})}s();var Ke=`matter`,qe=[`discovering`,`pase`,`commissioning`,`done`];function Je(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function Ye(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 Xe({onClose:t,onCommissioned:n}){let{t:r}=Z(),s=X({kind:Ke}),[c,l]=o(null),u=s.data?.length??0,d=c??s.data?.[0]?.id??null,f=W(),[p,m]=o(``),[h,g]=o({phase:`idle`,failure:null,message:null}),_=h.phase===`discovering`||h.phase===`pase`||h.phase===`commissioning`,v=Se({brokerId:d??``,key:`commission`},{enabled:d!==null&&_,refetchInterval:_?400:!1});a(()=>{_&&Je(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 b=()=>{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})}}))},x=h.phase===`failed`?Ye(h.failure,h.message):null,S=x===null?null:r(x.key,{defaultValue:x.defaultValue}),C=(s.isSuccess===!0||s.data!==void 0)&&d===null;return i(ae,{open:!0,onOpenChange:e=>!e&&t(),children:e(we,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(pe,{children:i(K,{children:r(`integrations.addMatter.title`,{defaultValue:`Add Matter device`})})}),e(ue,{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.`})}),(C||u>1)&&!_&&h.phase!==`done`&&e(`div`,{className:`space-y-1.5`,children:[i(R,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(Ie,{kind:Ke,value:d,onChange:l})]}),!C&&e(`div`,{className:`space-y-1.5`,children:[i(R,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(q,{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(y,{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)})}),S!==null&&i(L,{message:S})]}),e(he,{children:[i(H,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),h.phase===`done`?i(H,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(H,{size:`sm`,disabled:_||C||p.trim().length===0,onClick:b,children:_?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})})}var Ze=1500;function Qe({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Z(),s=V(),c=(P({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?Ze:!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(y,{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(w,{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 $e(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 et=`devices`;function tt(e){return{id:et,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var nt=2e4,rt=100;function it({addonId:n,integrationId:s,onClose:l}){let u=ee(),{t:d}=Z(),f=c(),[p,h]=o(new Set),[g,_]=o(new Set),[v,b]=o(new Map),[S,C]=o(null),{data:w}=Te(),E=(w??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[D,k]=o(!0),A=B({addonId:n,integrationId:s}).data?.filters,j=A&&A.length>0?A:[tt(d)],[M,ne]=o(j.find(e=>e.isDefault)?.id??(j.some(e=>e.id===et)?et:j[0].id)),N=M!==et,P=te(),F=U({addonId:n,integrationId:s,page:1,pageSize:nt,filter:M}),I=F.refetch,L=P.mutate,R=r(()=>{L({addonId:n,integrationId:s},{onSettled:()=>{I()}})},[L,n,s,I]),z=t(null);a(()=>{let e=`${n}::${s}`;z.current===e||F.isLoading||(z.current=e,(F.data?.candidates.length??0)===0&&R())},[n,s,F.isLoading,F.data,R]);let V=P.isPending,H=P.isError?P.error instanceof Error?P.error.message:String(P.error):null,W=typeof P.data?.lastError==`string`&&P.data.lastError.length>0?P.data.lastError:null,G=F.data?.candidates??[],K=F.isError?F.error instanceof Error?F.error.message:String(F.error):null,q=De(),[J,ie]=o(null),ae=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})},[]),oe=r(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),se=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})},[]),ce=r(e=>{let t={};for(let n of e){let e=v.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[v]),le=r(async()=>{C(null);let e=[...p];if(e.length!==0)try{let t=ce(e),{jobId:r}=await q.mutateAsync({addonId:n,integrationId:s,filter:M,childNativeIds:e,...t?{perCandidate:t}:{},...E?{importLocations:D}:{}});ie(r),h(new Set),b(new Map)}catch(e){C(e instanceof Error?e.message:String(e))}},[p,ce,q,n,s,M,E,D]),ue=t(null),de=r(()=>{J===null||ue.current===J||(ue.current=J,I(),f.invalidateQueries({queryKey:[[`integrations`]]}),f.invalidateQueries({queryKey:[[`deviceManager`]]}))},[J,I,f]),pe=r(e=>{ne(e),h(new Set),_(new Set),b(new Map),C(null)},[]),Y=p.size,X=J!==null&&Y===0&&!q.isPending;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:l}),e(`div`,{className:`relative z-10 flex w-full max-w-3xl flex-col h-[85vh] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`min-w-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:d(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:d(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),e(`div`,{className:`flex items-center gap-3 shrink-0`,children:[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=>k(e.target.checked),className:`accent-primary`}),d(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),i(`button`,{onClick:l,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":d(`common.close`,`Close`),children:i(x,{className:`h-4 w-4`})})]})]}),e(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[(H??K??W)&&G.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:d(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:H??K??W})]})]})}),j.length>1&&i(at,{filters:j,activeFilter:M,onSelect:pe}),i(`div`,{className:`flex-1 min-h-0`,children:i(ye,{mode:`generic`,items:G,pageSize:rt,getKey:e=>e.childNativeId,getSearchText:$e,getFilterType:e=>e.type,filterOptions:fe(u),filterLabel:d(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:F.isLoading||V&&G.length===0,searchPlaceholder:d(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(H??K??W)&&G.length===0?``:d(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:R,disabled:V,title:d(`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(T,{className:`h-3.5 w-3.5 ${V?`animate-spin`:``}`}),d(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:d(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(ot,{candidate:e,expandable:!N,expanded:g.has(e.childNativeId),onToggleExpand:()=>oe(e.childNativeId),adoptedLabel:d(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:d(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=re(t.type,u),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:()=>ae(e),disabled:e.alreadyAdopted,"aria-label":p.has(e.childNativeId)?d(`integrations.adoptDevicesModal.deselect`,`Deselect`):d(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${p.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:p.has(e.childNativeId)&&i(m,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!N&&g.has(e.childNativeId),renderExpanded:N?void 0:e=>i(st,{candidate:e,hiddenChildIds:v.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>se(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:p.has(e.childNativeId)?`bg-primary/5`:``})})]}),S&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 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})]})}),J!==null&&i(Qe,{addonId:n,integrationId:s,jobId:J,onFinished:de}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[i(`div`,{}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:l,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`,{defaultValue:`Cancel`})}),e(`button`,{onClick:X?l:le,disabled:!X&&(Y===0||q.isPending),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,children:[q.isPending&&i(y,{className:`h-3.5 w-3.5 animate-spin`}),X?d(`integrations.close`,{defaultValue:`Close`}):d(`integrations.addSelected`,{defaultValue:`Add selected`}),!X&&Y>0?` (${Y})`:``]})]})]})]})]})}function at({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Z();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 ot({candidate:t,expandable:n,expanded:r,onToggleExpand:a,adoptedLabel:o}){let{t:s}=Z(),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?l:h,{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 st({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Z(),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?f:g,{className:`h-3 w-3`})})]},t.childNativeId)})})}s();function ct(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...ct(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function lt(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>ct(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function ut(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 dt({integrationId:t,addonId:r,name:a,kind:o,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=Z(),m=c(),{data:h,isLoading:g}=xe({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:b}=ce({addonId:r,nodeId:`hub`},{enabled:s===`account`}),x=n(()=>v?ut(v):null,[v]),S=Y(),C=(e,n)=>{S.mutate({id:t,settings:e,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return i(ae,{open:!0,onOpenChange:e=>!e&&f(),children:e(we,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(pe,{children:e(K,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,a]})}),i(ue,{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:_})]}),S.isPending?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(y,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):i(Le,{kind:l,onResolved:e=>{C({brokerId:e})},onBack:f}),S.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||b?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(y,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):i(Re,{addonId:r,configSchema:x,canTest:u,initialName:a,initialConfig:lt(x,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>C(e,t),onBack:f}):i(J,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function ft(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function pt(){let{t}=Z(),{integrationId:s}=Me(),l=c(),f=Ne(),[m,h]=je(),g=v(),[_,x]=o(!1),[ee,w]=o(!1),[T,E]=o(!1),O=r(e=>{E(!1),f(`/integrations`,{state:{integrationSeed:e}})},[f]),[k,te]=o(!1),[P,I]=o(!1),{data:L,isLoading:R}=de({id:s??``},{enabled:!!s}),{data:z}=ce({addonId:L?.addonId??``,nodeId:`hub`},{enabled:!!L?.addonId}),{data:B,isSuccess:V}=Te(),H=n(()=>{let e=L?.addonId;return!e||!V?null:(B??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[B,L?.addonId,V]),{data:U}=ie({}),W=n(()=>(U?.providers??[]).some(e=>e.addonId===L?.addonId),[U,L?.addonId]),q=H!==null,J=L?.info?.fixed===!0,re=n(()=>{let e=L?.addonId;return!e||!V?null:(B??[]).find(t=>t.addonId===e)?.brokerKind??null},[B,L?.addonId,V]),le=re===`matter`,fe=q?le?t(`integrations.addMatter.title`,{defaultValue:`Add Matter device`}):H===`device-adoption`?t(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):t(`integrations.addDevice`):t(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),Y=n(()=>{let e=L?.addonId;return!e||!V?!1:(B??[]).find(t=>t.addonId===e)?.canTest===!0},[B,L?.addonId,V]),X=n(()=>{let e=L?.addonId;return!e||!V?null:(B??[]).find(t=>t.addonId===e)?.mode??null},[B,L?.addonId,V]);a(()=>{m.get(`add`)===`1`&&q&&(w(!1),x(!0),h(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[m,q,h]);let he=z!=null&&Array.isArray(z.sections)&&z.sections.some(e=>e.fields.length>0),{data:xe}=Ce({addonId:L?.addonId??``,nodeId:`hub`},{enabled:!!L?.addonId&&X!==`account`}),Se=X!==null&&X!==`account`&&ft(xe),Ee=n(()=>L?.addonId?[L.addonId]:[],[L?.addonId]),{data:De}=G({projection:`slim`},{refetchInterval:3e4}),ke=[[`integrations`,`get`],{input:{id:s??``},type:`query`}],Ae=Oe({onMutate:async e=>{await l.cancelQueries({queryKey:ke});let t=l.getQueryData(ke);return t!=null&&l.setQueryData(ke,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&l.setQueryData(ke,r.previous)},onSettled:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Pe=oe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]}),f(`/integrations`)}}),Ie=ve({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Le=M({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Re=_e({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ve=be({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=n(()=>De??[],[De]),He=n(()=>{let e=new Map;for(let t of Q)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[Q]),Ue=r(e=>He.get(e)??null,[He]),{data:$}=ge(void 0),We=n(()=>j($),[$]),Ke=r(e=>f(`/devices/${String(e)}`),[f]),qe=n(()=>{let e=L?.id;return e?Q.filter(t=>{let n=We(t);return n.kind===`resolved`&&n.integration.id===e}):[]},[Q,L?.id,We]),Je=n(()=>$===void 0?null:N(qe).length,[$,qe])??`…`;return R?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`})]}):L?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(F,{items:[{label:t(`integrationDetail.integrations`,`Integrations`),onClick:()=>f(`/integrations`)},{label:L.name}]}),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(mt,{addonId:L.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:L.name}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[L.addonId,` · `,Je,` `,t(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[W&&e(`button`,{onClick:()=>E(!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:t(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[i(S,{className:`h-3.5 w-3.5`}),t(`integrationDetail.scanNetwork`,`Scan network`)]}),!J&&e(`button`,{onClick:()=>{w(!1),x(!0)},disabled:!q,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:fe,children:[i(d,{className:`h-3.5 w-3.5`}),fe]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ae.isPending?`opacity-60`:``} ${L.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:t(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(ne,{checked:L.enabled,onCheckedChange:e=>Ae.mutate({id:s,enabled:e}),disabled:Ae.isPending,"aria-label":L.enabled?t(`integrationDetail.disableIntegration`,`Disable integration`):t(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${L.enabled?`text-success`:`text-foreground-subtle`}`,children:L.enabled?t(`integrationDetail.enabled`,`Enabled`):t(`integrationDetail.disabled`,`Disabled`)}),Ae.isPending&&i(y,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),X!==`standalone`&&(he||H===`device-adoption`)&&e(`button`,{onClick:()=>te(!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`}),t(`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:t(`integrations.logs`,{defaultValue:`View logs`}),children:[i(D,{className:`h-3 w-3`}),t(`integrations.logs`,{defaultValue:`Logs`})]}),i(me,{label:t(`integrationDetail.restart`,`Restart`),icon:u,title:t(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:L.name}),description:t(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:Je}),confirmLabel:t(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ie.isPending,action:()=>Ie.mutateAsync({addonId:L.addonId})}),!J&&s&&i(me,{label:t(`integrations.delete`,{defaultValue:`Delete`}),icon:p,title:t(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:t(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:L.name,count:Je}),confirmLabel:t(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Pe.isPending,action:()=>Pe.mutateAsync({id:s})})]})]}),Se&&i(Be,{nodeId:null,addonIds:Ee,level:`global`,surface:`integration`,title:t(`integrations.settings`,{defaultValue:`Settings`})}),i(ye,{context:`integration-detail`,devices:Q,trpc:g.trpcClient,integrationOf:We,forceIntegrationId:L.id,urlScope:`root`,lsKey:`integration-detail:${L.addonId}`,resolveIntegrationIcon:Fe,resolveParent:Ue,onNavigate:Ke,batchActions:{remove:Le.mutate,disable:Re.mutate,enable:Ve.mutate},...J?{}:{onDeleteDevice:e=>Le.mutate({deviceId:e.id})}}),_&&s&&le&&!ee&&i(Xe,{onClose:()=>x(!1),onCommissioned:()=>w(!0)}),_&&s&&H===`device-adoption`&&(!le||ee)&&i(it,{addonId:L.addonId,integrationId:s,onClose:()=>{x(!1),w(!1)}}),_&&s&&H===`device-provider`&&i(Ge,{open:_,integrationId:s,addonId:L.addonId,onClose:()=>x(!1)}),T&&L&&i(ze,{open:T,scope:{addonId:L.addonId,label:L.name},onClose:()=>E(!1),onSetupIntegration:O}),k&&s&&H!==null&&X!==null&&i(dt,{integrationId:s,addonId:L.addonId,name:L.name,kind:H,mode:X,brokerKind:re,canTest:Y,trpc:g.trpcClient,onClose:()=>te(!1)}),P&&i(ae,{open:!0,onOpenChange:e=>!e&&I(!1),children:e(we,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(pe,{className:`mb-0`,children:e(K,{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:L.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[L.addonId,s?` · ${s}`:``]})]})}),i(ue,{className:`min-h-0 overflow-hidden p-0`,children:i(se,{addonId:L.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:t(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:s??``})})]}),e(`button`,{onClick:()=>f(`/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`}),t(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function mt({addonId:e}){let t=ke(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{pt as IntegrationDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o,k as s,o as c,x as l,z 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{En as d,Fn as f,In as p,Ui as m,V as h,fr as g,hr as _,tn as v,yn as y,zt as b}from"./player-overlays-BFb5SWA9.js";import{Vr as x}from"./client-Rf8T-Qxy.js";import{t as S}from"./settings-2-DUxYPsEJ.js";import{$t as C,Er as w,Li as ee,Tr as T,Yr as E,bn as D,br as O,en as k,hn as A,ji as te,ni as ne}from"./src-BfkcE2yV.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{c as re,d as M,dr as N,gr as P,o as F,r as I,s as L,u as R,ur as z}from"./index-DUGfFMf0.js";import{t as B}from"./AdminPage-CV0QlJ3B.js";import{t as V}from"./NodeAddonsSettingsPanel-BfighMS8.js";import{t as H}from"./AddonAssetIcon-B_mf6RWm.js";o();function U(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=P(),s=o.get(F),c=i===null?null:o.get(i),l=o.get(L),u=n(()=>R({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${M(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function K({isActive:e}){let{t}=j();return r(ne,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function q({capName:t,addonId:n,isActive:i}){let{t:a}=j(),o=c(),s=ee({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),l=s.isPending;return e(E,{size:`sm`,variant:i?`secondary`:`primary`,disabled:l,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!i}),children:[l?r(g,{className:`h-3 w-3 animate-spin`}):r(i?v:p,{className:`h-3 w-3`}),i?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function ie({addonId:e,displayName:t}){let{t:n}=j(),i=c(),a=te({onSuccess:()=>{for(let e of W)i.invalidateQueries({queryKey:e})}});return r(A,{label:n(`integrationHub.addonControls.restart`,`Restart`),icon:d,size:`sm`,title:n(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:n(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`),confirmLabel:n(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}o();var J=600,Y=s(null);function X({id:n,title:i,icon:a,actions:o,framed:s=!1,children:c}){let{t:d}=j(),f=u(Y),p=t(null),m=`integration-section-${n}`;ae(p,f,n);let g=e(l,{children:[f===null?null:r(N,{to:f.sectionHref(n),"aria-label":d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),title:d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:r(_,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?r(`div`,{ref:p,className:`scroll-mt-4`,children:r(D,{headingId:m,title:i,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&r(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),r(`h2`,{id:m,className:`${h} min-w-0 flex-1`,children:i}),g]}),c]})}function ae(e,t,n){let r=t?.requestedSection===n,a=t?.integrationId;i(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,a,e])}o();var Z=`max-h-72`;function oe({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s,error:c=null,lead:l,panels:u=[],settingsContent:d}){let{t:f}=j(),p=u.filter(e=>e.placement!==`end`),m=u.filter(e=>e.placement===`end`);return e(`div`,{className:`flex flex-col gap-4`,children:[r(se,{addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}),c!==null&&r(T,{message:c}),l,r(Q,{panels:p}),r(X,{id:re,title:f(`integrationHub.addonIntegrationBody.settings`,`Settings`),icon:S,children:d===void 0?r(V,{nodeId:`hub`,addonIds:[t],level:`global`,capability:i}):d}),r(le,{addonId:t}),r(Q,{panels:m})]})}function Q({panels:e}){return r(l,{children:e.map(e=>r(X,{id:e.id,title:e.title,icon:e.icon,children:e.content},e.id))})}function se({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}){return e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-surface px-2 py-1.5 sm:px-3`,"data-testid":`integration-status-strip`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[r(K,{isActive:a}),o,r(`span`,{className:`break-all font-mono text-[11px] text-foreground-subtle`,children:t})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[s,r(q,{capName:i,addonId:t,isActive:a}),r(ie,{addonId:t,displayName:n})]})]})}var ce=[{kind:`logs`,labelKey:`common.logs`,icon:y},{kind:`events`,labelKey:`common.events`,icon:m}];function le({addonId:t}){let{t:n}=j(),[i,o]=a(`logs`);return r(X,{id:I,title:n(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:r(`div`,{role:`group`,"aria-label":n(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:ce.map(({kind:t,labelKey:a,icon:s})=>e(`button`,{type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(s,{className:`h-3 w-3`,"aria-hidden":!0}),n(a)]},t))}),children:i===`logs`?r(k,{addonId:t,maxHeight:Z,showFilters:!1}):r(C,{addonId:t,category:`addon.*`,maxHeight:Z})})}var ue=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,de=`border-primary bg-primary/10 text-primary font-medium`,fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,pe={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function $({label:t,groups:n,selectedId:i,hrefFor:a}){let o=n.length>1;return r(`nav`,{"aria-label":t,className:o?`flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)] sm:items-start sm:gap-x-3`:`flex flex-col`,children:n.map(t=>e(`div`,{role:`group`,"aria-label":t.label,className:o?`flex min-w-0 flex-col gap-1 sm:col-span-2 sm:grid sm:grid-cols-subgrid sm:items-start`:`min-w-0`,children:[o&&r(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle sm:pt-2`,children:t.label}),e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.entries.map(e=>r(me,{entry:e,current:e.id===i,href:a(e.id)},e.id)),t.install&&e(N,{to:x(t.install.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[r(f,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`span`,{className:`truncate`,children:t.install.label})]})]})]},t.id))})}function me({entry:t,current:n,href:i}){let a=t.state===`ok`;return e(N,{to:i,"aria-current":n?`true`:void 0,className:`${ue} ${n?de:fe}`,"data-testid":`integration-pill-${t.id}`,children:[r(H,{addonId:t.id,fallback:t.fallbackIcon,tileClassName:``,size:`sm`}),r(`span`,{className:`truncate`,children:t.name}),t.showState!==!1&&r(he,{entry:t,quiet:a})]})}function he({entry:t,quiet:n}){return e(l,{children:[r(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${pe[t.state]}`,"aria-hidden":!0}),r(`span`,{className:n?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.stateLabel})]})}o();function ge({icon:t,title:i,subtitle:a,groups:o,isLoading:s,emptyTitle:c,emptyDescription:u,legacyGroupParam:d,trailing:f,embedded:p=!1}){let{t:m}=j(),h=n(()=>o.flatMap(e=>e.entries),[o]),g=n(()=>h.map(e=>e.id),[h]),_=n(()=>{let e={};for(let t of o){let n=t.entries[0];n!==void 0&&(e[t.id]=n.id)}return e},[o]),v=U({ids:g,answered:!s,legacyGroupParam:d??null,groupFirst:_}),y=h.find(e=>e.id===v.selectedId)??null,b=n(()=>y===null?null:{integrationId:y.id,requestedSection:v.requestedSection,sectionHref:e=>v.hrefFor(y.id,e)},[y,v]),x=s?null:r($,{label:m(`integrationHub.integrationHub.integrations`,`{{title}} integrations`,{title:i}),groups:o,selectedId:v.selectedId,hrefFor:e=>v.hrefFor(e)}),S=s?r(O,{children:r(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:m(`common.loading`,`Loading…`)})}):e(l,{children:[v.staleId!==null&&r(ve,{staleId:v.staleId,shownName:y?.name??null}),y!==null&&b!==null?r(Y.Provider,{value:b,children:r(`div`,{role:`region`,"aria-label":y.name,"data-testid":`integration-body`,children:y.render()},y.id)}):r(_e,{groups:o,title:c,description:u}),f]});return p?e(`div`,{className:`space-y-3`,"data-testid":`integration-hub-embedded`,children:[x,S]}):r(B,{icon:t,title:i,subtitle:a,nav:x,children:S})}function _e({groups:t,title:n,description:i}){let a=t.find(e=>e.install!==void 0)?.install;return r(O,{children:r(w,{title:n,description:i,action:a?r(N,{to:x(a.capability),children:e(E,{variant:`primary`,size:`sm`,children:[r(f,{className:`mr-1 h-3.5 w-3.5`}),a.label]})}):void 0})})}function ve({staleId:t,shownName:n}){let{t:i}=j();return e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(b,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),e(`span`,{children:[r(z,{i18nKey:`integrationHub.staleIntegration.notice`,values:{id:t},components:{mono:r(`span`,{className:`font-mono text-foreground`})}}),n!==null&&e(l,{children:[` `,r(z,{i18nKey:`integrationHub.staleIntegration.showing`,values:{name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})]})]})]})}export{U as i,oe as n,G as r,ge as t};
|
|
@@ -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,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as u,En as d,Fn as f,Ni as p,Oi as m,Pn as h,Ti as g,dt as _,fr as ee,gn as v,gt as te,kn as ne,vn as y,vr as re}from"./player-overlays-BFb5SWA9.js";import{t as ie}from"./table-2-uZMmLo6a.js";import{At as ae,F as b,Ja as oe,Mt as se,Tr as x,Yr as S,_o as C,ad as w,at as T,fi as E,hs as ce,kt as D,od as O,oo as le,pd as k,ps as ue,r as A,us as j}from"./src-BfkcE2yV.js";import{t as M}from"./i18n-BDPAB47Q.js";import{t as N}from"./useTranslation-BJr-n0es.js";import{cr as P,gr as F,mr as de,pr as fe}from"./index-DUGfFMf0.js";import{t as I}from"./AdminPage-CV0QlJ3B.js";import"./useEventInvalidation-DL02cGAU.js";import{t as L}from"./device-integration-icon-BN3tz8Fb.js";import{i as pe,n as me,r as R,t as he}from"./ScanNetworkModal-wDrkbkgj.js";s();function ge({rows:t,isExpanded:r,onToggleExpand:a,onOpen:s,renderExpanded:c,searchPlaceholder:l,emptyLabel:u}){let[d,f]=o(``),p=n(()=>{let e=d.trim().toLowerCase();return e.length===0?t:t.filter(t=>`${t.name} ${t.addonId}`.toLowerCase().includes(e))},[d,t]);return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(y,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(w,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l,"aria-label":l,className:`pl-8`})]}),p.length===0?i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:u}):i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:p.map(e=>i(_e,{integration:e,expanded:r(e),onToggleExpand:a,onOpen:s,renderExpanded:c},e.id))})]})}function _e({integration:t,expanded:n,onToggleExpand:r,onOpen:a,renderExpanded:o}){return e(`article`,{"data-testid":`integration-card-${t.id}`,className:k(`flex min-w-0 flex-col gap-2 overflow-x-clip rounded-lg border border-border bg-surface p-3`,n&&`sm:col-span-2 lg:col-span-3`),children:[i(ve,{integration:t,expanded:n,onToggleExpand:r,onOpen:a}),n?i(`div`,{className:`min-w-0`,children:o(t)}):null]})}function ve({integration:t,expanded:n,onToggleExpand:r,onOpen:a}){let{t:o}=N(),s=n?o(`integrations.integrationColumns.collapse`,`Collapse`):o(`integrations.integrationColumns.expand`,`Expand`);return e(`div`,{className:`relative flex min-w-0 items-stretch gap-3`,children:[i(S,{type:`button`,variant:`ghost`,"aria-label":o(`integrations.openNamed`,{name:t.name,defaultValue:`Open {{name}}`}),onClick:()=>a(t),className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(z,{integration:t}),e(`div`,{className:`pointer-events-none relative z-10 flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:[i(T,{status:t.status,className:`shrink-0`}),i(`p`,{className:`text-[11px] text-foreground-muted`,children:o(`integrations.integrationColumns.deviceCount`,{count:t.deviceCount})}),i(`div`,{className:`pointer-events-auto mt-auto self-end`,children:i(O,{type:`button`,variant:`ghost`,size:`sm`,icon:n?u:g,"aria-label":s,"aria-expanded":n,onClick:e=>V(e,t.addonId,r)})})]})]})}function z({integration:t}){return e(`div`,{className:`pointer-events-none relative z-10 flex w-28 shrink-0 flex-col items-center gap-1 lg:w-24`,children:[i(P,{type:t.addonId,size:`xl`}),i(`p`,{className:`w-full text-center text-xs font-semibold text-foreground`,children:t.name}),i(B,{addonId:t.addonId})]})}function B({addonId:t}){return i(`p`,{className:`w-full text-center text-[10px] leading-tight text-foreground-subtle`,children:t.split(`-`).map((t,n)=>e(`span`,{children:[n>0?e(l,{children:[`-`,i(`wbr`,{})]}):null,t]},`${t}-${String(n)}`))})}function V(e,t,n){e.stopPropagation(),n(t)}s();var H=`camstack.admin.integrations.view`;function U(e){return e===`table`||e===`grid`}function W(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function G(e=W()){if(e===null)return`table`;try{let t=e.getItem(H);return U(t)?t:`table`}catch{return`table`}}function K(e,t=W()){if(t!==null)try{t.setItem(H,e)}catch{}}function ye(){let[e,t]=o(()=>G());return[e,r(e=>{t(e),K(e)},[])]}s();function q(e=!0){a(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}s();function be(e,t){let[n,r]=o(!1);return a(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}s();function xe({providerId:t,onImport:n,onSkip:r}){let{t:s}=N(),[c,l]=o(new Set),u=le(),d=u.data,f=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(f)return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=d??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,r=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[i(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&i(m,{className:`h-3 w-3 text-primary-foreground`})}),i(p,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),o&&i(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}var J=`(hover: none) and (pointer: coarse)`;function Y(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(J).matches}catch{return!0}}s();function X({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l}=N(),u=de(),[d,f]=o(``),p=t(null),{data:m,isLoading:h}=ue();a(()=>{h||!Y()||p.current?.focus()},[h]);let g=n(()=>{let e=m??[],t=d.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[m,d]);if(h)return i(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let _=c!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(y,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(w,{ref:p,type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":l(`integrations.searchProviders`,`Search integrations…`)})]}),i(`div`,{className:`grid grid-cols-2 gap-2`,children:g.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId,o=_;return e(`button`,{type:`button`,disabled:o,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!o)if(n){let e=t.existingInstances[0].id;s(),u(`/integrations/${e}`)}else r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[t.iconUrl?i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),i(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?i(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,a?i(ee,{className:`h-4 w-4 animate-spin text-primary`}):n?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[i(v,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null]},t.addonId)})}),g.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(m??[]).length===0?l(`integrations.noProviders`):l(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function Se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Ce=2e4;function we({open:t,onClose:r,seed:s=null}){let{t:u}=N(),d=de(),f=c(),[p,m]=o(`picker`),[h,g]=o(null),[_,v]=o(null),[ne,y]=o(`manual`),[re,ie]=o(null),[ae,b]=o(``),[se,x]=o(null),[S,C]=o(null),[w,T]=o(!1),[ce,D]=o({}),[O,k]=o(``),A=s?.config.host,M=s===null?``:`${s.addonId}\0${s.name}\0${typeof A==`string`?A:``}`;t&&s!==null&&O!==M&&(k(M),g(s.addonId),b(s.name),D({...s.config}),m(`config`));let P=ue(void 0,{enabled:t&&s!==null}),{data:F}=E({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),fe=n(()=>F?Se(F):null,[F]),I=j({onSuccess:()=>f.invalidateQueries({queryKey:[[`integrations`]]})}),L=le(),me=L.data;a(()=>{if(!t||s===null)return;let e=P.data?.find(e=>e.addonId===s.addonId);e&&(T(e.canTest),y(e.discoveryMode))},[t,s,P.data]),a(()=>{p!==`discovery`||!_||!h||L.isPending||L.data||L.mutate({addonId:h})},[p,_,h,L]);let he=oe({onSuccess:()=>f.invalidateQueries({queryKey:[[`deviceManager`]]})});function ge(e,t,n,r,i,a,o,s){if(!I.isPending){if(g(e),T(s),y(n),b(r),C(null),o===`broker`){if(!a){C(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}ie(a),m(`broker`);return}if(o===`account`){m(`config`);return}_e(e,r)}}async function _e(e,t){try{let n=await I.mutateAsync({addonId:e,name:t,settings:{}});r(),H(),d(`/integrations/${n.id}?add=1`)}catch{}}async function ve(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});v(t.id),x(t.id),ne===`auto`||ne===`both`?m(`discovery`):V(t.id,{openAdd:!0})}catch{}}async function z(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:ae,settings:{brokerId:e}});x(t.id),v(t.id),V(t.id)}catch{}}async function B(e){if(h){for(let t of e){let e=me?.find(e=>e.stableId===t);e&&await he.mutateAsync({addonId:h,candidate:e,...se===null?{}:{integrationId:se}})}V()}}function V(e,t){let n=e??_??h;r(),H(),n&&d(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function H(){m(`picker`),g(null),v(null),y(`manual`),ie(null),b(``),x(null),C(null),T(!1),D({}),k(``)}function U(){r(),H()}q(t);let W=I.isPending,G=be(W,Ce);if(!t)return null;let K={picker:u(`integrations.newIntegration`),config:u(`integrations.configureIntegration`),discovery:u(`integrations.importDevices`),broker:u(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ye=W?h:null,J=I.error,Y=W&&!G;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:Y?void 0:U}),e(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:K[p]}),i(`button`,{onClick:U,disabled:Y,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:i(te,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[J&&!W&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:J instanceof Error?J.message:String(J)}),p===`picker`&&e(l,{children:[S&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:S}),i(X,{onSelect:ge,onClose:U,pendingAddonId:ye})]}),p===`config`&&h&&i(R,{addonId:h,configSchema:fe??null,canTest:w,initialName:typeof ce.host==`string`?ae:void 0,initialConfig:{...ce},onSave:ve,onBack:()=>{D({}),m(`picker`)}},M.length>0?M:h),p===`broker`&&re&&i(pe,{kind:re,onResolved:e=>{z(e)},onBack:()=>m(`picker`)}),p===`discovery`&&_&&i(xe,{providerId:_,onImport:B,onSkip:V})]}),W&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(ee,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:u(`integrations.creating`,{defaultValue:`Creating integration…`})}),!G&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),G&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:u(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(`button`,{onClick:U,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:u(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function Te({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=N();return e(`div`,{className:`flex items-center gap-2.5`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:i(n?u:g,{className:`h-3.5 w-3.5`})}),i(P,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[i(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Ee(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:M.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(Te,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:M.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>M.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:M.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>i(T,{status:e.status})}]}s();function De(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var Z=`expand`;function Oe(){let{t}=N(),s=de(),c=fe(),u=_(),[p]=F(),[m,g]=ye(),[ee,v]=o(!1),[te,y]=o(null),oe=r(()=>{y(null),v(!0)},[]),S=r(()=>{v(!1),y(null)},[]),w=r(e=>{E(!1),y(e),v(!0)},[]),[T,E]=o(!1);a(()=>{let e=me(c.state);e!==null&&(y(e),v(!0),s(`/integrations`,{replace:!0,state:null}))},[c.state,s]);let O=p.get(`setup`);a(()=>{O===null||O.length===0||(y({addonId:O,name:O,config:{}}),v(!0))},[O]);let le=r(()=>E(!0),[]),ue=r(()=>E(!1),[]);A([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),A([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:j,isLoading:M,isError:P,refetch:pe}=ce(void 0),{data:R,isLoading:_e,isError:ve,refetch:z}=C({projection:`slim`}),B=n(()=>R??[],[R]),V=n(()=>j??[],[j]),H=n(()=>{let e=new Map;for(let t of B)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[B]),U=n(()=>ae(j),[j]),W=n(()=>{let e=new Map;for(let t of se(B)){let n=U(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[B,U]),G=n(()=>V.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:De(e),deviceCount:W.get(e.id)??0})),[V,W]),K=p.get(Z),q=r(e=>{let t=new URLSearchParams(window.location.search);t.get(Z)===e?t.delete(Z):t.set(Z,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),be=r(e=>s(`/integrations/${e.id}`),[s]),xe=r(e=>H.get(e)??null,[H]),J=r(e=>s(`/devices/${String(e)}`),[s]),Y=r(e=>i(D,{context:`integration-detail`,devices:B,trpc:u.trpcClient,integrationOf:U,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:L,resolveParent:xe,onNavigate:J}),[B,u.trpcClient,U,xe,J]),X=r(e=>K===e.addonId,[K]),Se=n(()=>Ee({isExpanded:X,onToggleExpand:q}),[X,q]),Ce=r(e=>`${e.name} ${e.addonId}`,[]),Te=r(e=>e.addonId,[]),Oe=r(()=>{pe(),z()},[pe,z]),Q=P===!0||ve===!0,$=!Q&&(M||_e||j===void 0||R===void 0),ke=V.length>0,Ae=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:ie},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:re}];return e(I,{icon:h,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(b,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:m,onChange:g,options:Ae,testId:`integrations-view`}),i(`button`,{onClick:Oe,disabled:$,className:`flex items-center gap-1 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 disabled:opacity-50`,title:t(`common.refresh`,`Refresh`),children:i(d,{className:k(`h-3.5 w-3.5`,$&&`animate-spin`)})}),e(`button`,{onClick:le,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:t(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[i(ne,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:oe,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`,children:[i(f,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&i(x,{message:t(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:Oe}),$&&i(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>i(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&!ke&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[i(`p`,{className:`text-sm`,children:t(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),i(`p`,{className:`text-xs mt-1`,children:t(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&!$&&ke&&m===`table`&&i(D,{mode:`generic`,items:G,getKey:Te,getSearchText:Ce,columns:Se,onRowClick:be,isExpanded:X,renderExpanded:Y,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),!Q&&!$&&ke&&m===`grid`&&i(ge,{rows:G,isExpanded:X,onToggleExpand:q,onOpen:be,renderExpanded:Y,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(we,{open:ee,onClose:S,seed:te}),i(he,{open:T,onClose:ue,onSetupIntegration:w})]})}export{Oe as IntegrationsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bi as c,Br as l,Di as u,En as d,Fn as f,Gt as p,Ht as m,Jr as h,Jt as g,Ni as _,O as v,Ri as y,Sr as b,Ti as x,Ur as S,V as C,Vn as w,Wi as T,Wt as E,Yr as D,Zi as O,aa as k,gr as A,gt as j,hr as M,ht as N,k as P,ln as F,lr as I,mn as L,oa as R,oi as ee,on as z,sa as te,sr as ne,st as re,vi as ie,vt as B,yn as V,z as ae}from"./player-overlays-BFb5SWA9.js";import{Qr as oe,Xr as se,_n as ce}from"./client-Rf8T-Qxy.js";import{t as le}from"./boxes-EVKxMyl3.js";import{n as ue,r as de,t as fe}from"./speaker-CKpoIyB7.js";import{t as H}from"./user-round-C4iC5VEd.js";import{Ao as pe,Co as me,Fo as he,Fr as U,Ha as ge,Ho as _e,Io as ve,Lo as ye,Lr as W,Nr as G,Oo as be,Po as xe,Pr as Se,Qr as Ce,R as we,Sn as K,Ua as Te,Un as Ee,Vr as De,Wa as Oe,Wn as ke,Yr as q,_o as Ae,_r as je,ad as J,bo as Me,dr as Ne,ed as Pe,fn as Fe,fr as Ie,gr as Le,hr as Re,jo as ze,ko as Be,ni as Ve,od as He,pn as Ue,pr as We,qa as Ge,sd as Ke,xo as qe,yo as Je,yt as Ye}from"./src-BfkcE2yV.js";import{t as Y}from"./i18n-BDPAB47Q.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{dr as Xe,gr as Ze,m as Qe,mr as $e}from"./index-DUGfFMf0.js";import{t as et}from"./AdminSectionedPage-BBzHFRdX.js";import{a as tt,n as nt,r as rt}from"./linked-devices-model-CwgRN3Vm.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function it(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function at(e,t){let n=it(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function ot(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function st(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function ct(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>st(e,n)).map(e=>e.id));return e.filter(e=>!(st(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function lt(e,t){return ct(e,t).filter(e=>e.parentDeviceId===null)}function ut(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function dt(e,t){return ut(e,t).length}function ft(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function pt(e,t){return t.map(t=>({name:t,members:at(e,t)}))}var mt={camera:_,hub:ue,container:le,light:A,siren:F,switch:p,sensor:te,thermostat:g,climate:R,button:ie,"event-emitter":N,update:de,notifier:T,script:V,automation:B,lock:I,cover:c,valve:D,humidifier:h,"water-heater":l,fan:S,"media-player":fe,"alarm-panel":L,control:z,presence:H,weather:ee,vacuum:y,"lawn-mower":E,image:b,smoke:k};function $({type:e,className:t}){return n(mt[e]??ie,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function ht({device:e}){let t=U(Z(e),`compact`);return n(gt,{online:e.online,deviceName:t})}function gt({online:e,deviceName:t}){return n(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":Y.t(`locations.deviceGlyphs.aria`,{name:t,state:e?Y.t(`common.online`):Y.t(`common.offline`)}),title:e?Y.t(`common.online`):Y.t(`common.offline`)})}function _t({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=X(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return n(Ne,{open:t,onOpenChange:e=>e?void 0:p(),children:e(We,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(Le,{children:n(je,{children:a})}),e(Ie,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),t&&n(we,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(Re,{children:[n(q,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(q,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function vt({room:e,cameras:r,fleet:i}){let{t:a}=X(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(bt,{camera:e,byId:o},e.id))})}function yt(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function bt({camera:t,byId:r}){let{t:a}=X(),s=U(Z(t),`full`),c=o(),l=$e(),[u,d]=i(!1),[f,p]=i(null),m=Te({deviceId:t.id}),h=rt({status:m.status,data:m.data,error:m.error===null||m.error===void 0?null:m.error}),g=Oe(),_=h.kind===`present`?h:null,y=ge({deviceId:t.id,slotRef:_?.slot.slotRef??``},{enabled:u&&_!==null}),b=_===null?[]:nt(_.slot,_.value),x=b.map(e=>e.deviceId),S=(y.data?.candidates??[]).map(yt),C=new Set(S.map(e=>e.id)),w=x.filter(e=>!C.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),T=[...S,...w],E=(y.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),D=async e=>{if(_!==null){p(null);try{await g.mutateAsync({deviceId:t.id,slotRef:_.slot.slotRef,value:tt(_.value,e)}),await m.refetch(),await c.invalidateQueries({queryKey:[[`deviceManager`]]}),d(!1)}catch(e){p(e instanceof Error?e.message:String(e))}}},O=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type}),n(Xe,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(G,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId);return i===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i.online?a(`common.online`):a(`common.offline`)})]})}}];return e(`section`,{className:`min-w-0 ${v}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${P} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(G,{device:Z(t),form:`full`})}),e(q,{variant:`ghost`,size:`sm`,onClick:()=>l(Qe(t.id)),children:[n(M,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(q,{variant:`outline`,size:`sm`,disabled:_===null,onClick:()=>d(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),h.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),h.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:h.reason})}),h.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),f!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:f}),_!==null&&(b.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(K,{columns:O,rows:b,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(_t,{open:u,title:a(`locations.links.pickTitle`,{camera:s}),items:T,listState:y.status===`error`?`failed`:y.data===void 0?`pending`:`answered`,lockedIds:x,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:E},busy:g.isPending,onConfirm:e=>void D(e),onClose:()=>d(!1)})]})}a();function xt({name:t,description:a,busy:o,onSave:s}){let{t:c}=X(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(ke,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(`textarea`,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`p`,{className:`mt-1 ${ae}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function St(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Ct=` none`;function wt({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=X();if(r.length===0)return null;let c=[{value:Ct,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(ke,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(Pe,{id:`location-zone-${t}`,value:i??Ct,disabled:a,onChange:e=>{let t=e.target.value;if(t===Ct){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Tt(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Et({name:e,icon:t,busy:r,onPick:i}){return n(Ke,{value:t,onPick:i,fallbackGlyph:ne,clearGlyph:O,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Dt(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:oe(n.icon)??`map-pin`}function Ot(e){return`${e.kind}:${String(e.device.id)}`}function kt(e,t,n){return e.flatMap(e=>{let r=ft(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}a();function At({name:r,members:a,devices:o,busy:c,icon:l,description:u,onRename:f,onDelete:p,onRebuildLinks:h,onAddDevices:g,onPickIcon:_,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=X(),[T,E]=i(!1),[D,O]=i(r),k=Fe(a,t(()=>({searchText:e=>[e.name,...ft(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[A,M]=i(()=>new Set),N=e=>M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),F=t(()=>kt(k.rows,o,A),[k.rows,o,A]),I=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?n(jt,{row:e,onToggle:()=>N(e.device.id)}):n(Mt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t.device}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.device.online?C(`common.online`):C(`common.offline`)})]})}],L=()=>{O(r),E(!1)},R=async()=>{let e=D.trim();if(e.length===0||e===r){L();return}await f(e),E(!1)},ee=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:w,disabled:c,onClick:()=>{O(r),E(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:d,separatorBefore:!0,disabled:c,onClick:()=>void h()},{id:`delete`,label:C(`common.delete`,`Delete`),icon:m,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}];return e(`section`,{className:`min-w-0 ${v}`,children:[e(`header`,{className:`${P} flex min-h-9 items-center gap-1.5`,children:[n(Et,{name:r,icon:l,busy:c,onPick:_}),T?e(s,{children:[n(J,{value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&R(),e.key===`Escape`&&L()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(q,{type:`button`,size:`sm`,onClick:()=>void R(),children:C(`common.save`,`Save`)}),n(He,{type:`button`,variant:`ghost`,icon:j,onClick:L,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(q,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:r}),children:C(`locations.room.add`)}),n(Ye,{items:ee,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(wt,{name:r,zones:b,zoneKey:x,busy:c,onChange:S}),n(xt,{name:r,description:u,busy:c,onSave:y}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(Ue,{state:k.state,facets:k.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:r}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:k.setSearch,onToggleFacet:k.toggleFacet,onClear:k.clear})}),a.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:C(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):n(K,{columns:I,rows:F,rowKey:Ot,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function jt({row:t,onToggle:r}){let{t:i}=X(),{device:a,accessories:o,open:s}=t,c=U(Z(a),`compact`),l=s?u:x;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(q,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type}),n(Xe,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(G,{device:Z(a),form:`compact`})})]})}function Mt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(Xe,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(G,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function Nt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=X(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(K,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Et,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(J,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(q,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(m,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Night zone” for the bedrooms — and shows up before them in the app’s camera filter.`)})}a();function Pt({busy:t,onCreate:r}){let{t:a}=X(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(J,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(q,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(j,{className:`h-3.5 w-3.5`})})]}):e(q,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function Ft({busy:t,onCreate:r}){let{t:a}=X(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(J,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(q,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(j,{className:`h-3.5 w-3.5`})})]}):e(q,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function It(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function Lt({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=X(),c=t(()=>It(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(Ce,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var Rt={searchText:e=>[e.name],facetValue:e=>e.type};function zt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=X(),d=De(),f=W(),p=e=>d===null?e.name:Se(Z(e),`compact`,d,f),[m,h]=i([]),[g,_]=i(``),v=Fe(r,Rt),y=v.rows,b=t(()=>y.map(e=>e.id),[y]),x=t(()=>m.filter(e=>b.includes(e)),[m,b]),S=y.length>0&&x.length===y.length,w=t(()=>{let e=new Map;for(let t of r)e.set(t.id,dt(a,t.id));return e},[r,a]),T=x.reduce((e,t)=>e+(w.get(t)??0),0),E=e=>h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),D=()=>h(S?[]:b),O=()=>{g.length===0||x.length===0||(l(x,g),h([]),_(``))},k=o.map(e=>({value:e,label:e})),A=[{key:`select`,width:`w-8`,headerRender:()=>n(Ee,{checked:S,onChange:D,"aria-label":S?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(Ee,{checked:x.includes(e.id),onChange:()=>E(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:p(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=ot(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type}),n(Xe,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(G,{device:Z(t),form:`compact`})}),r!==null&&n(Ve,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>w.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:w.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>n(Pe,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:p(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...k]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:C,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:ae,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(Ue,{state:v.state,facets:v.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onClear:v.clear}),x.length>0&&e(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:x.length}),T>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:T})}`]}),n(Pe,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:g,onChange:e=>_(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...k]}),n(q,{type:`button`,size:`sm`,onClick:O,disabled:s||g.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(q,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>h([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(K,{columns:A,rows:y,rowKey:e=>e.id,minWidthPx:720,emptyMessage:v.active?u(`locations.filter.noMatch`):c})]})}function Bt(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function Vt(e,t){let n=t.map(Bt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:ce({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ht=`device-manager:linked-devices`;function Ut(e){return{deviceId:e.deviceId,slotRef:Ht,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var Wt=`__unassigned__`;function Gt(){let{t:r}=X(),a=o(),s=re(),{data:c,isLoading:l}=qe(),{data:u}=Me(),{data:d}=Je(),{data:f}=me(),{data:p,isLoading:m}=Ae({projection:`slim`}),h=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=Ge({onSuccess:h}),_=be({onSuccess:h}),v=xe({onSuccess:h}),y=pe({onSuccess:h}),b=ve({onSuccess:h}),x=he({onSuccess:h}),S=_e({onSuccess:h}),C=Be({onSuccess:h}),w=ze({onSuccess:h}),T=ye({onSuccess:h}),E=Oe(),D=t(()=>(p??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null})),[p]),O=c??[],k=t(()=>pt(D,O),[D,O]),[A,j]=Ze(),M=A.get(`tab`),N=M===`zones`||M===`camera-links`?M:`locations`,P=A.get(`room`),F=t(()=>lt(D,O),[D,O]),I=P===Wt,L=I?null:P!==null&&k.some(e=>e.name===P)?P:k[0]?.name??null,R=L===null?null:k.find(e=>e.name===L)??null,ee=I?Wt:L??`__unassigned__`,z=L??k[0]?.name??null,te=t(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),ie=e=>{j(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},B=l||m,V=v.isPending||_.isPending||g.isPending||b.isPending,ae=async e=>{await g.mutateAsync({name:e})},oe=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},ce=async e=>{let t=Vt(e,D);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
|
|
2
|
-
`);if(!await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:e,lines:n}),confirmLabel:r(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of t.entries)try{await E.mutateAsync(Ut(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),i.length>0&&await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
|
|
3
|
-
`)}),confirmLabel:`OK`})},le=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;await s({title:r(`locations.deleteLocation`,`Delete location`),message:r(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:e,extra:n}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await _.mutateAsync({name:e,cascade:!0})},ue=async e=>{await s({title:r(`locations.deleteZone`,`Delete zone`),message:r(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:e}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await C.mutateAsync({name:e})},de=async(e,t)=>{await b.mutateAsync({location:e,icon:t})},fe=async(e,t)=>{await x.mutateAsync({location:e,description:t})},H=f??[],U=async(e,t)=>{await T.mutateAsync({location:e,zone:t})},ge=(e,t)=>{for(let n of e)v.mutate({deviceId:n,location:t})},[W,G]=i(null),Se=t(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),Ce=n(Lt,{rooms:te,...N===`locations`?{unassignedCount:F.length}:{},value:N===`locations`?ee:z??``,unassignedValue:Wt,onChange:ie}),we=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[B&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),Ce,I||R===null?n(zt,{rows:F,fleet:D,locations:O,busy:V,emptyMessage:B?r(`common.loading`,`Loading…`):r(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:ge}):n(At,{name:R.name,members:R.members,devices:D,busy:V,icon:Dt(u,se(R.name)),onPickIcon:e=>de(R.name,e),description:St(d,se(R.name)),onSaveDescription:e=>fe(R.name,e),zones:H,zoneKey:Tt(H,se(R.name)),onChangeZone:e=>U(R.name,e),onRename:e=>oe(R.name,e),onDelete:()=>le(R.name,it(D,R.name).length),onRebuildLinks:()=>ce(R.name),onAddDevices:()=>G(R.name)},R.name),O.length===0&&!B&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),n(_t,{open:W!==null,title:r(`locations.room.addDialogTitle`,{room:W??``}),items:Se,listState:m?`pending`:`answered`,lockedIds:W===null?[]:(k.find(e=>e.name===W)?.members??[]).map(e=>e.id),lockedNote:r(`locations.room.alreadyHere`),suggestions:{heading:r(`locations.room.suggestedUnassigned`),ids:F.map(e=>e.id)},busy:v.isPending,onConfirm:e=>{W!==null&&ge(e,W),G(null)},onClose:()=>G(null)})]}),K=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[Ce,n(vt,{room:z,cameras:z===null?[]:it(D,z).filter(e=>e.isCamera),fleet:D})]});return n(et,{icon:ne,title:r(`locations.locations`,`Locations`),subtitle:r(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:N===`zones`?n(Ft,{busy:S.isPending,onCreate:e=>S.mutateAsync({name:e})}):n(Pt,{busy:g.isPending,onCreate:ae}),sections:[{id:`locations`,label:r(`locations.locations`,`Locations`),content:we},{id:`camera-links`,label:r(`locations.cameraLinks`,`Camera links`),content:K},{id:`zones`,label:r(`locations.zones`,`Zones`),content:n(Nt,{zones:H,busy:V,onRename:(e,t)=>w.mutateAsync({from:e,to:t}),onDelete:ue,onPickIcon:(e,t)=>S.mutateAsync({name:e,icon:t})})}]})}export{Gt as LocationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x 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{D as l,En as u,Fn as d,Gn as f,Ht as p,In as m,Kr as h,L as g,Oi as _,Tn as v,Z as y,_n as b,bt as x,dt as S,fn as C,fr as w,gt as T,lr as ee,ri as E,rn as te,tn as D,xn as ne,zt as O}from"./player-overlays-BFb5SWA9.js";import{Hr as re,Rr as ie,Ur as ae,ir as k}from"./client-Rf8T-Qxy.js";import{t as A}from"./boxes-EVKxMyl3.js";import{l as j,s as oe}from"./video-B6REUv1P.js";import{t as se}from"./log-in-l36ik9Wr.js";import{$s as ce,Bs as le,Ei as M,Fs as ue,Lu as de,Ns as fe,Ps as pe,Qs as me,Rs as he,Sn as ge,Ti as N,Tr as _e,Un as ve,Us as ye,Vs as be,Ws as xe,Xs as Se,Yr as P,Ys as Ce,Zs as we,_n as Te,_o as Ee,ad as De,bn as Oe,br as ke,ed as Ae,ic as je,nc as Me,ni as F,rc as Ne,yn as Pe}from"./src-BfkcE2yV.js";import{t as I}from"./i18n-BDPAB47Q.js";import{t as L}from"./useTranslation-BJr-n0es.js";import"./mount-DL02cGAU.js";import{S as Fe,a as R,dr as Ie,fr as Le,gr as Re,i as z}from"./index-DUGfFMf0.js";import{t as ze}from"./AdminSectionedPage-BBzHFRdX.js";import{t as B}from"./AdminPage-CV0QlJ3B.js";import{t as Be}from"./NodeAddonsSettingsPanel-BfighMS8.js";import{n as V,r as Ve,t as H}from"./IntegrationHub-GrzjNslW.js";import{n as U,t as W}from"./addon-display-names-BkwMrExv.js";o();var G=5e3,K=`network-access`,He={connected:!1,endpoint:null};function Ue(){let{t:e}=L(),n=s(),i=M({capName:`network-access`},{refetchInterval:G}),o=N(void 0,{refetchInterval:G}),c=t(()=>W(o.data??[]),[o.data]),l=t(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:c.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,c]),[u,d]=a(null),[f,p]=a({}),m=(e,t)=>{let r=t?.addonId;n.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),d(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{d(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);p(e=>({...e,[n]:r}))},g=Ne({onSuccess:m,onError:h}),_=je({onSuccess:m,onError:h}),v=[{id:K,label:e(`system.remoteAccess.remoteAccess`,`Remote access`),install:{capability:K,label:e(`system.remoteAccess.addTunnel`,`Add tunnel`)},entries:l.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:j,...U(e.isActive),render:()=>r(V,{addonId:e.addonId,displayName:e.displayName,capName:K,isActive:e.isActive,badges:r(Ge,{addonId:e.addonId}),error:f[e.addonId]??null,primaryAction:r(Ke,{addonId:e.addonId,busyId:u,onStart:e=>{d(e),g.mutate({addonId:e})},onStop:e=>{d(e),_.mutate({addonId:e})}})})}))}];return r(H,{embedded:!0,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),groups:v,isLoading:i.isLoading,emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`)})}function We(e){let{data:t}=Me({addonId:e},{refetchInterval:G,retry:!1}),n=t?ie.safeParse(t):null;return n?.success?n.data:He}function Ge({addonId:t}){let{t:n}=L(),i=We(t);return e(c,{children:[r(F,{variant:i.connected?`success`:`default`,className:Ve,children:i.connected?n(`system.remoteAccess.connected`,`Connected`):n(`system.remoteAccess.disconnected`,`Disconnected`)}),i.endpoint&&e(`a`,{href:i.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(h,{className:`h-3 w-3`}),i.endpoint.url]})]})}function Ke({addonId:t,busyId:n,onStart:i,onStop:a}){let{t:o}=L(),s=We(t),c=n===t;return s.connected?e(P,{size:`sm`,variant:`secondary`,disabled:c,onClick:()=>a(t),children:[c?r(w,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),o(`system.remoteAccess.stop`,`Stop`)]}):e(P,{size:`sm`,variant:`primary`,disabled:c,onClick:()=>i(t),children:[c?r(w,{className:`h-3 w-3 animate-spin`}):r(m,{className:`h-3 w-3`}),o(`system.remoteAccess.start`,`Start`)]})}o();var qe=3e4,q=`turn-provider`;function Je(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Ye(){let{t:n}=L(),i=M({capName:`turn-provider`},{refetchInterval:qe}),a=N(void 0,{refetchInterval:qe}),o=de(),s=o.data??[],c=t(()=>W(a.data??[]),[a.data]),u=t(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:c.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,c]),d=[{id:q,label:n(`system.turnServers.turnProviders`,`TURN providers`),install:{capability:q,label:n(`system.turnServers.addProvider`,`Add provider`)},entries:u.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:f,...U(e.isActive),render:()=>r(V,{addonId:e.addonId,displayName:e.displayName,capName:q,isActive:e.isActive,panels:[{id:`ice-servers`,title:n(`system.turnServers.discoveredIceServers`,`Discovered ICE servers`),icon:f,content:r(Xe,{addonId:e.addonId,enabled:e.isActive})}]})}))}];return r(H,{embedded:!0,icon:f,title:n(`system.turnServers.turnServers`,`TURN Servers`),subtitle:n(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),groups:d,isLoading:i.isLoading,emptyTitle:n(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:n(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),trailing:r(Oe,{headingId:`turn-combined-ice`,title:n(`system.turnServers.combinedIceServerListAll`,`Combined ICE server list — all enabled providers`),icon:f,actions:r(P,{size:`sm`,variant:`secondary`,onClick:()=>o.refetch(),disabled:o.isFetching,children:n(`common.refresh`,`Refresh`)}),children:r(`div`,{className:l,children:s.length===0?r(`div`,{className:`text-xs text-foreground-subtle`,children:n(`system.turnServers.noServersFromEnabledProviders`,`No servers from enabled providers.`)}):r(`div`,{className:`flex flex-col gap-3`,children:s.map((t,n)=>{let i=Array.isArray(t.urls)?t.urls:[t.urls];return e(`div`,{className:`rounded border border-border bg-surface`,children:[(t.username||t.credential)&&e(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[t.username&&e(`span`,{children:[r(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,r(`span`,{className:`text-foreground`,children:t.username})]}),t.credential&&e(`span`,{children:[r(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,r(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),r(`ul`,{className:`divide-y divide-border`,children:i.map(e=>r(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},n)})})})})})}function Xe({addonId:e,enabled:n}){let i=de({addonId:e},{enabled:n,retry:!1}),a=t(()=>Je(i.data??[]),[i.data]),o=n?i.isLoading?`Loading…`:a.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return r(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:o===null?r(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>r(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):r(`div`,{className:`text-xs text-foreground-subtle`,children:o})})}o();var Ze={lan:f,wifi:x,docker:A,vpn:ee,loopback:b,other:b},Qe={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},$e=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function et(n){let{t:i}=L(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:l}=n,u=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),d=t(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return $e.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=e=>n.mode===`single`?n.value===e:n.value.includes(e),p=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return u.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Ze[t]??b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Qe[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=f(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(_,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[r(O,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}var J=[{role:`appConnections`,get title(){return I.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return I.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return I.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return I.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return I.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.internalHelp`)}}],tt=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function Y(e,t){return e.inUse.includes(t)}function nt(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return Y(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&Y(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:re}:{kind:`set`,input:n}}function rt(e){return J.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var it={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function at({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=L(),[f,m]=a(``),[h,g]=a(``),[_,v]=a(null),[y,b]=a(null),x=()=>{let e=ae(f);if(!e.ok){v(e.reason);return}v(null),m(``),g(``),c(e.baseUrl,h.trim())},S=(e,t)=>{let n=nt(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),s(n.input)}},C=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(O,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=it[e.kind]??it.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...J.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=Y(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(ve,{checked:a&&s,disabled:!a||i,onChange:()=>S(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(P,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(p,{className:`h-3 w-3`})}):null}],w=t===void 0?[]:rt(t);return e(ke,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:J.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:tt})]})]}),w.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:w.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(P,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),y!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(O,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),r(P,{size:`sm`,variant:`secondary`,onClick:()=>{s({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(P,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(ge,{columns:C,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(De,{value:f,onChange:e=>{m(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),_!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:_})]}),r(`div`,{className:`w-48`,children:r(De,{value:h,onChange:e=>g(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(P,{size:`sm`,variant:`secondary`,disabled:i||f.trim()===``,onClick:x,children:[r(d,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function ot(){let{t:n}=L(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},d=he(void 0,{refetchInterval:3e4}),f=ue(void 0),p=xe({onSuccess:c}),m=be({onSuccess:e=>{w(e.addresses),c()}}),h=t(()=>d.data?.interfaces??[],[d.data]),g=pe({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),_=ye({onSuccess:c}),y=fe({onSuccess:c}),b=le({onSuccess:c}),x=_.error?.message??y.error?.message??b.error?.message??null,S=_.isPending||y.isPending||b.isPending,[C,w]=a([]),[T,ee]=a(!1);i(()=>{!T&&f.data&&(w(f.data.addresses),ee(!0))},[f.data,T]);let E=f.data?.addresses??[],D=t(()=>{if(C.length!==E.length)return!0;let e=[...C].toSorted(),t=[...E].toSorted();return e.some((e,n)=>e!==t[n])},[C,E]);return e(B,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(P,{size:`sm`,variant:`secondary`,onClick:()=>{d.refetch(),f.refetch(),g.refetch()},disabled:d.isLoading,children:[r(u,{className:`h-3 w-3 ${d.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(Oe,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(P,{size:`sm`,variant:`secondary`,onClick:()=>m.mutate(void 0),disabled:m.isPending||p.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(te,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(P,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||p.isPending,children:[r(v,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),D&&r(P,{size:`sm`,variant:`secondary`,onClick:()=>{w(E)},disabled:p.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(P,{size:`sm`,variant:`primary`,onClick:()=>{p.mutate({addresses:[...C]})},disabled:!D||p.isPending,children:[r(ne,{className:`h-3 w-3`}),p.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:l,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),r(et,{mode:`multiple`,interfaces:h,value:C,onChange:w,disabled:p.isPending,emptyMessage:d.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r(at,{book:g.data,loading:g.isLoading,saving:S,error:x,onSetRole:e=>_.mutate({...e}),onAdd:(e,t)=>y.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}o();var st={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},X=5e3,Z=`mesh-network`,ct=3e4,lt={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function ut(){let{t:e}=L(),n=M({capName:`mesh-network`},{refetchInterval:X}),i=N(void 0,{refetchInterval:X}),a=t(()=>W(i.data??[]),[i.data]),o=t(()=>(n.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive})),[n.data,a]),s=[{id:Z,label:e(`system.meshNetworks.meshNetworks`,`Mesh networks`),install:{capability:Z,label:e(`system.meshNetworks.addMesh`,`Add mesh`)},entries:o.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:f,...U(t.isActive),render:()=>r(V,{addonId:t.addonId,displayName:t.displayName,capName:Z,isActive:t.isActive,badges:r(dt,{addonId:t.addonId}),primaryAction:r(ft,{addonId:t.addonId}),panels:[{id:`status`,title:e(`system.meshNetworks.status`,`Status`),icon:A,content:r(pt,{addonId:t.addonId})}]})}))}];return r(H,{embedded:!0,icon:A,title:e(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:e(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),groups:s,isLoading:n.isLoading,emptyTitle:e(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:e(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`)})}function Q(e){let{data:t,isLoading:n}=Ce({addonId:e},{refetchInterval:X,retry:!1}),r=t?k.safeParse(t):null;return{status:r?.success?r.data:lt,isLoading:n}}function dt({addonId:t}){let{t:n}=L(),{status:i}=Q(t);return e(c,{children:[r(F,{variant:i.joined?`success`:`default`,className:Ve,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(F,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})})]})}function ft({addonId:t}){let{t:i}=L(),o=s(),[l,u]=a(!1),[d,f]=a(null),p=S(),{status:m}=Q(t),h=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),g=ce(),_=Se({onSuccess:h}),v=me({onSuccess:h}),y=n(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await g.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await bt(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?k.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,h,g,p]),b=n(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return r(c,{children:m.joined?e(c,{children:[e(P,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:t}),children:[_.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(oe,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(P,{size:`sm`,variant:`ghost`,onClick:b,children:[r(T,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(P,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[r(se,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function pt({addonId:t}){let{t:n}=L(),{status:i}=Q(t),a=we({addonId:t},{refetchInterval:ct,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(_e,{message:i.error}),r(mt,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${st[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[r(h,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(gt,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function mt({status:t}){let{t:n}=L();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?ht(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function ht(e){let t=e-Date.now();if(t<0)return I.t(`system.meshNetworks.expiredAgo`,{when:yt(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return I.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?I.t(`system.meshNetworks.expiryHours`,{count:r}):I.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function gt({peers:i,loading:a}){let{t:o}=L(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(F,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(F,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(`button`,{onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(E,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(`button`,{onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(E,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(F,{variant:_t(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,vt(t.txBytes),` · ↓ `,vt(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?yt(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(w,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(ge,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function _t(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function vt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function yt(e){let t=Date.now()-e;return t<6e4?I.t(`system.meshNetworks.justNow`):t<36e5?I.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?I.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):I.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}function bt(e){return new Promise(t=>setTimeout(t,e))}var $=`/system/identity?tab=certificates`;function xt(){let{t}=L();return r(B,{embedded:!0,children:e(`div`,{className:g,children:[r(Be,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:t(`system.localAccess.lanHttp`,`LAN HTTP`),description:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Ie,{className:`underline`,to:$,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function St({value:n,onChange:i}){let{t:a}=L(),{data:o}=Ee({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(Ae,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function Ct(){let t=S(),[i,o]=a(null);return r(B,{embedded:!0,children:e(`div`,{className:g,"data-testid":`network-diagnostics`,children:[r(Pe,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(Te,{trpc:t.trpcClient,serverUrl:y(),deviceId:i,cameraField:r(St,{value:i,onChange:o})})]})})}var wt=[`certificate`,`certificates`,`https`];function Tt(){let{t:e}=L(),[t]=Re();if(wt.includes(t.get(`tab`)??``))return r(Le,{to:$,replace:!0});let n=Fe(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return r(ze,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(xt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r(ot,{})},{id:R.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(Ue,{}),ownedParams:z},{id:R.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(ut,{}),ownedParams:z},{id:R.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(Ye,{}),ownedParams:z},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(Ct,{})}]})}export{Tt as NetworkPage};
|