@camstack/addon-admin-ui 1.2.108 → 1.2.110
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/dist/assets/{AddLocationWizard-C1QuDd5l.js → AddLocationWizard-B2pYT5l3.js} +1 -1
- package/dist/assets/{AddonCollectionPage-CAMY7BSp.js → AddonCollectionPage-BM--U5wi.js} +1 -1
- package/dist/assets/Addons-C1fP2vbH.js +1 -0
- package/dist/assets/{AdminTabs-DIHki8py.js → AdminTabs-CLeY5YpY.js} +1 -1
- package/dist/assets/{AiProfiles-DiQNZe9S.js → AiProfiles-B4OqaOyL.js} +2 -2
- package/dist/assets/{BrokerForm-mfcucCqe.js → BrokerForm-BBcYgkU0.js} +1 -1
- package/dist/assets/{Build-Bd3bm4rZ.js → Build-Clz-9wEa.js} +4 -4
- package/dist/assets/{Capabilities-CT-vp-yT.js → Capabilities-GMmZShHl.js} +1 -1
- package/dist/assets/{CapabilityBadges-5yUqlEI8.js → CapabilityBadges-ls5u4iSS.js} +1 -1
- package/dist/assets/Cluster-B0miuhVw.js +11 -0
- package/dist/assets/{Data-DLHWqZce.js → Data-BsJaaX8N.js} +1 -1
- package/dist/assets/DetectionIntelligence-DwAMtJfh.js +1 -0
- package/dist/assets/{DeviceAggregateSection-CJc0z5bD.js → DeviceAggregateSection-CfbUJ--n.js} +1 -1
- package/dist/assets/DeviceDetail-kxj_2AT4.js +2 -0
- package/dist/assets/Devices-CrvA2yT8.js +1 -0
- package/dist/assets/EmbedPlayerPage-5qdw9AQ5.js +1 -0
- package/dist/assets/Events-C0HDOEKf.js +1 -0
- package/dist/assets/{FormBuilder-DfwoGzWg.js → FormBuilder-Sl0aUAjm.js} +1 -1
- package/dist/assets/Identity-3wRL60eh.js +1 -0
- package/dist/assets/IntegrationDetail-DYdXG7zw.js +1 -0
- package/dist/assets/Integrations-DWirlHH2.js +1 -0
- package/dist/assets/Integrations-GhhEgWTs.js +1 -0
- package/dist/assets/{Logs-BI78-0VJ.js → Logs-OCVO9mBC.js} +1 -1
- package/dist/assets/{MotionZonesSettings-gEbDj9Pj.js → MotionZonesSettings-DztkSAzw.js} +1 -1
- package/dist/assets/{MyAccess-Dq5YfsIV.js → MyAccess-C1FnwEV1.js} +1 -1
- package/dist/assets/Network-C1tyUle7.js +1 -0
- package/dist/assets/NodeAddonsSettingsPanel-C51CLAUV.js +1 -0
- package/dist/assets/NodeInferenceDevices-BheDiA_Y.js +1 -0
- package/dist/assets/Notifications-2oJHn7yF.js +1 -0
- package/dist/assets/Pipeline-BWgUjIBu.js +1 -0
- package/dist/assets/{Plates-LVOTLRQ_.js → Plates-B1CFXuYH.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-ByMo4smL.js → PrivacyMaskSettings-BhcRGnjg.js} +1 -1
- package/dist/assets/{ProviderIcon-BuQT-C1f.js → ProviderIcon-CSGCWRat.js} +1 -1
- package/dist/assets/Recordings-CVBJ-fTE.js +1 -0
- package/dist/assets/{ScanNetworkModal-DO_NYOIO.js → ScanNetworkModal-DP3Q1lJf.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-COTXt9Av.js → SceneMonitorEditor-CC_SRLkY.js} +1 -1
- package/dist/assets/Scenes-CMobnBno.js +1 -0
- package/dist/assets/{Settings-UaBYAyll.js → Settings-Boxw0bXQ.js} +1 -1
- package/dist/assets/{Showroom-BO0DQHWe.js → Showroom-BLra8xK_.js} +1 -1
- package/dist/assets/{Terminal-D6BI2-dB.js → Terminal-DJKkbuyK.js} +3 -3
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-6VfZqYHt.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-MSGGSFff.js} +1 -1
- package/dist/assets/{bell-ring-COnGH5xz.js → bell-ring-BrNXSpTM.js} +1 -1
- package/dist/assets/{boxes-BqAi_ZYu.js → boxes-BBQZcZmf.js} +1 -1
- package/dist/assets/circle-check-big-BA325w7j.js +1 -0
- package/dist/assets/{circle-x-CAQ2kQrS.js → circle-x-duYSDFk4.js} +1 -1
- package/dist/assets/clock-C2SeIGR3.js +1 -0
- package/dist/assets/{copy-D25tAWbr.js → copy-sWO8ojL1.js} +1 -1
- package/dist/assets/{debounced-invalidate-Dd9oPYKq.js → debounced-invalidate-CsEaF8m7.js} +1 -1
- package/dist/assets/{dist-Cz-CwPmU.js → dist-B2d_n790.js} +1 -1
- package/dist/assets/dist-CwHxBEa6.js +349 -0
- package/dist/assets/{download-DC6CvEwh.js → download-BG5cgMLB.js} +1 -1
- package/dist/assets/{face-bbox-HBoy_dVM.js → face-bbox-CuCo2m34.js} +1 -1
- package/dist/assets/{hostInit-BZyW6qkD.js → hostInit-BXhxZCos.js} +1 -1
- package/dist/assets/index-TIovJNJd.js +4 -0
- package/dist/assets/{key-round-CkImMp76.js → key-round-DFB6Ddil.js} +1 -1
- package/dist/assets/{layers-DR9qbaZc.js → layers-Dg2FntHR.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-ed3637b6.js → mf-entry-bootstrap-0-78ce8935.js} +2 -2
- package/dist/assets/{pencil-D-rxGNNf.js → pencil-DfqU4z4Q.js} +1 -1
- package/dist/assets/play-B850xDzN.js +1 -0
- package/dist/assets/{player-overlays-wniETo4u.js → player-overlays-BrCS3AFF.js} +1 -1
- package/dist/assets/plus-C1RBhRwm.js +1 -0
- package/dist/assets/power-DSSFcNbH.js +1 -0
- package/dist/assets/{radio-dB0UNm47.js → radio-PpN-ewHt.js} +1 -1
- package/dist/assets/{refresh-cw-srKCTv_-.js → refresh-cw-BP3l62v-.js} +1 -1
- package/dist/assets/remoteEntry-y4f0U6fp.js +1 -0
- package/dist/assets/rotate-ccw-BiOviRuW.js +1 -0
- package/dist/assets/rotate-cw-PvJE7LD3.js +1 -0
- package/dist/assets/{send-DouvNKBS.js → send-BhFSH1Dx.js} +1 -1
- package/dist/assets/{server-BQtqKhWd.js → server-DTziPc-j.js} +1 -1
- package/dist/assets/{shield-Df5MsuC2.js → shield-DloVBwF4.js} +1 -1
- package/dist/assets/square-BxxA8zwF.js +1 -0
- package/dist/assets/{square-check-big-DRcEphPQ.js → square-check-big-DCkSuowJ.js} +1 -1
- package/dist/assets/{src-IW6snE8b.js → src-CTpgEWRF.js} +17 -17
- package/dist/assets/src-Db_n2ue2.js +349 -0
- package/dist/assets/{star-DSf9DLF0.js → star-mh10UPuW.js} +1 -1
- package/dist/assets/{undo-2-D8E8Za4o.js → undo-2-BdzAmJva.js} +1 -1
- package/dist/assets/{use-scenes-feed-DZbJbkzy.js → use-scenes-feed-DuRQEHSx.js} +1 -1
- package/dist/assets/useEventInvalidation-DI7nUUUv.js +1 -0
- package/dist/assets/{video-DMGYxQJX.js → video-B8iXv4k7.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-ByOZvjdD.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-vbnrVEeZ.js} +2 -2
- package/dist/assets/{wifi-DPLmik5h.js → wifi-CA7EJ_s4.js} +1 -1
- package/dist/assets/{zap-D-TFU8vN.js → zap-Bm8mq3x-.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +270 -2
- package/package.json +1 -1
- package/dist/assets/Addons-bWB0ZmER.js +0 -1
- package/dist/assets/Cluster-BPFw3CEh.js +0 -11
- package/dist/assets/DetectionIntelligence-B4PBUQWJ.js +0 -1
- package/dist/assets/DeviceDetail-bORj-EYN.js +0 -2
- package/dist/assets/Devices-D88uoW-K.js +0 -1
- package/dist/assets/EmbedPlayerPage-BQ5bsryo.js +0 -1
- package/dist/assets/Events-D9XRueHk.js +0 -1
- package/dist/assets/Identity-43Eya081.js +0 -1
- package/dist/assets/IntegrationDetail-CwEQCSYB.js +0 -1
- package/dist/assets/Integrations-Bj0zg-09.js +0 -1
- package/dist/assets/Integrations-tWtIaZju.js +0 -1
- package/dist/assets/Network-0uDqECDb.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-CAyKEQpD.js +0 -1
- package/dist/assets/NodeInferenceDevices-CnDRCNxR.js +0 -1
- package/dist/assets/Notifications-zU06XSrO.js +0 -1
- package/dist/assets/Pipeline-B5A-GVGG.js +0 -1
- package/dist/assets/Recordings-TSgV5nm4.js +0 -1
- package/dist/assets/Scenes-DgDtCzMz.js +0 -1
- package/dist/assets/circle-check-big-BQVyFP9A.js +0 -1
- package/dist/assets/clock-DGWYKseh.js +0 -1
- package/dist/assets/dist-B_SWpX_l.js +0 -349
- package/dist/assets/index-Cp84SBzW.js +0 -4
- package/dist/assets/play-s0iikQHY.js +0 -1
- package/dist/assets/plus-BVcSfMMt.js +0 -1
- package/dist/assets/power-CcdufSlh.js +0 -1
- package/dist/assets/remoteEntry-B2zHiyBK.js +0 -1
- package/dist/assets/rotate-ccw-CY-1yf9N.js +0 -1
- package/dist/assets/rotate-cw-DKLLB8dt.js +0 -1
- package/dist/assets/square-CFDIb2ZA.js +0 -1
- package/dist/assets/src-CsxD-27Y.js +0 -349
- package/dist/assets/useEventInvalidation-CsNvM4qI.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,o,q as s,x as c,z as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as u}from"./player-overlays-wniETo4u.js";import{$r as d,Br as f,Ci as p,Cr as m,Dr as h,Er as g,Fr as _,Gr as v,I as y,J as ee,Mr as b,N as x,Sr as S,T as te,Tr as C,Ur as w,Wt as T,_i as E,at as D,br as O,gi as k,gn as A,hi as j,jn as M,jr as N,jt as ne,nt as re,w as ie,xi as P,xr as F,yi as I,yr as L}from"./src-IW6snE8b.js";import{mt as R}from"./src-CsxD-27Y.js";import{t as z}from"./ProviderIcon-BuQT-C1f.js";import{t as B}from"./circle-x-CAQ2kQrS.js";import{t as V}from"./FormBuilder-DfwoGzWg.js";import{t as H}from"./plus-BVcSfMMt.js";import{i as ae,n as U,r as W,t as oe}from"./ScanNetworkModal-DO_NYOIO.js";import{t as se}from"./refresh-cw-srKCTv_-.js";import{t as G}from"./rotate-cw-DKLLB8dt.js";import{t as ce}from"./wifi-DPLmik5h.js";import{A as le,C as K,I as q,J as ue,K as J,P as de,R as fe,W as pe,X as me,Y as he,a as Y,f as ge,k as _e,m as ve,o as ye,r as be,t as xe,z as Se}from"./index-Cp84SBzW.js";var Ce=J(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]);n();function we(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...we(n.fields));return t}function Te(t,n,r){let[a,o]=s(`idle`),[c,l]=s({}),u=i(()=>{let e=[];for(let n of t.sections)e.push(...we(n.fields));return e},[t]),d=u.length>0&&r!==void 0,f=e(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:e(async()=>{if(!r)return;let e=u.filter(e=>{let t=n[e];return t!=null&&String(t).trim()!==``});if(e.length===0)return;o(`testing`);let t={};for(let n of e)t[n]={status:`probing`};l(t);let i=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await r(e,n[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of i)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),o(`idle`)},[r,u,n]),clearProbeResult:f}}n();function X(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(...X(n.fields));return t}function Z(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Q(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Q(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function Ee(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function De({open:t,integrationId:n,addonId:a,onClose:u}){let{t:f}=xe(),p=o(),[m,h]=s({}),[v,y]=s(!1),[b,x]=s(null),[S,te]=s(Ee),C=w({addonId:a},{enabled:t}),T=C.data?.deviceType??null,E=_({addonId:a,type:T??R.Camera},{enabled:t&&C.isSuccess&&T!==null}),D=E.data??null;l(()=>{t&&(h(D?Q(D.sections.flatMap(e=>e.fields)):{}),te(Ee()),y(!1),x(null))},[t,n,D]);let O=i(()=>({...m,_probeRequestId:S}),[m,S]),k=g({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),A=d(),j=e(async(e,t)=>{y(!0);let n=await A.mutateAsync({addonId:a,type:T??R.Camera,key:e,value:t,formValues:O});return n.status===`ok`&&n.suggestedValues&&h(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))Z(e[i])&&!Z(a)&&(r[i]=a,t=!0);return t?r:e}),n},[A,a,O,T]),{testAllStatus:M,hasProbeFields:N,probeResults:ne,handleTestAll:re,clearProbeResult:ie}=Te(D??{sections:[]},m,j);async function P(e){x(null);try{await k.mutateAsync({addonId:a,type:T??R.Camera,config:m,integrationId:n}),e?h(D?Q(D.sections.flatMap(e=>e.fields)):{}):u()}catch(e){x(e instanceof Error?e.message:String(e))}}if(!t)return null;let F=X((D?.sections??[]).flatMap(e=>e.fields)).filter(e=>Z(m[e])),I=F.length===0,L=C.isLoading||T!==null&&E.isLoading,z=C.isError||C.isSuccess&&T===null||E.isError||E.isSuccess&&D===null;return r(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[c(`div`,{className:`absolute inset-0 bg-black/60`,onClick:u}),r(`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:[r(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.addDevice`)}),c(`button`,{onClick:u,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:c(be,{className:`h-4 w-4`})})]}),c(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:L?c(`div`,{className:`flex items-center justify-center py-8`,children:c(K,{className:`h-5 w-5 animate-spin text-primary`})}):z?r(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[c(Y,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),r(`div`,{className:`space-y-1`,children:[c(`p`,{className:`text-xs font-medium text-destructive`,children:`Provider unavailable`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:[`The addon `,c(`span`,{className:`font-mono`,children:a}),` is not ready or does not support manual device creation. Check that the integration is online and try again.`]})]})]}):c(V,{schema:D,values:m,onChange:h,onTestField:j,probeResults:ne,onClearProbe:ie})}),!z&&!L&&r(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[r(`button`,{type:`button`,onClick:()=>y(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:[r(`span`,{className:`flex items-center gap-2`,children:[c(ve,{className:`h-3.5 w-3.5`}),`Test logs`,c(`span`,{className:`font-mono text-[9px] opacity-60`,children:S.slice(0,14)})]}),c(fe,{className:`h-3.5 w-3.5 transition-transform ${v?`rotate-180`:``}`})]}),v&&c(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:c(ee,{addonId:a,requestId:S,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!z&&!L&&(b||F.length>0)&&c(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:r(`div`,{className:`flex items-start gap-2`,children:[c(Y,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),c(`p`,{className:`text-[11px] text-destructive`,children:b||`Required: ${F.join(`, `)}`})]})}),r(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:u,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`)}),!z&&N&&r(`button`,{type:`button`,onClick:re,disabled:M===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[M===`testing`?c(K,{className:`h-3.5 w-3.5 animate-spin`}):c(ce,{className:`h-3.5 w-3.5`}),`Test All`]})]}),r(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:()=>P(!0),disabled:z||!I||k.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`)}),c(`button`,{onClick:()=>P(!1),disabled:z||!I||k.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:k.isPending?f(`integrations.saving`):f(`integrations.save`)})]})]})]})]})}var Oe=1500;function ke({addonId:e,integrationId:t,jobId:n,onFinished:i}){let{t:a}=xe(),o=L(),s=(S({addonId:e,integrationId:t},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?Oe:!1}).data??[]).find(e=>e.jobId===n);if(!s)return null;let l=s.state===`running`,u=s.processed,d=s.total>0?Math.round(u/s.total*100):0;!l&&s.finishedAt!==null&&i();let f=[`${u}/${s.total} ${a(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];s.adopted>0&&f.push(`${s.adopted} ${a(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),s.alreadyAdopted>0&&f.push(`${s.alreadyAdopted} ${a(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),s.failed>0&&f.push(`${s.failed} ${a(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return r(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[r(`div`,{className:`flex items-center gap-2`,children:[l?c(K,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):s.failed>0?c(Y,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):s.state===`cancelled`?c(B,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):c(de,{className:`h-3.5 w-3.5 text-primary shrink-0`}),c(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&c(`button`,{onClick:()=>o.mutate({jobId:n}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:a(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),c(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:c(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),s.results.filter(e=>e.outcome===`failed`).slice(0,5).map(e=>r(`p`,{className:`text-[11px] text-destructive`,children:[e.childNativeId,`: `,e.error]},e.childNativeId))]})}function Ae(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(` `)}n();var $=`devices`,je={id:$,label:`Devices`,isDefault:!0},Me=2e4,Ne=100;function Pe({addonId:n,integrationId:i,onClose:a}){let{t:o}=xe(),[u,d]=s(new Set),[f,p]=s(new Set),[h,g]=s(new Map),[_,v]=s(null),{data:ee}=E(),b=(ee??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[S,te]=s(!0),w=O({addonId:n,integrationId:i}).data?.filters,T=w&&w.length>0?w:[je],[D,k]=s(T.find(e=>e.isDefault)?.id??(T.some(e=>e.id===$)?$:T[0].id)),A=D!==$,j=m(),M=F({addonId:n,integrationId:i,page:1,pageSize:Me,filter:D}),N=M.refetch,ne=j.mutate,re=e(()=>{ne({addonId:n,integrationId:i},{onSettled:()=>{N()}})},[ne,n,i,N]),P=t(null);l(()=>{let e=`${n}::${i}`;P.current===e||M.isLoading||(P.current=e,(M.data?.candidates.length??0)===0&&re())},[n,i,M.isLoading,M.data,re]);let I=j.isPending,L=j.isError?j.error instanceof Error?j.error.message:String(j.error):null,R=typeof j.data?.lastError==`string`&&j.data.lastError.length>0?j.data.lastError:null,z=M.data?.candidates??[],B=M.isError?M.error instanceof Error?M.error.message:String(M.error):null,V=C(),[H,ae]=s(null),U=e(e=>{e.alreadyAdopted||d(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),W=e(e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),oe=e((e,t)=>{g(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})},[]),se=e(e=>{let t={};for(let n of e){let e=h.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[h]),ce=e(async()=>{v(null);let e=[...u];if(e.length!==0)try{let t=se(e),{jobId:r}=await V.mutateAsync({addonId:n,integrationId:i,filter:D,childNativeIds:e,...t?{perCandidate:t}:{},...b?{importLocations:S}:{}});ae(r),d(new Set),g(new Map)}catch(e){v(e instanceof Error?e.message:String(e))}},[u,se,V,n,i,D,b,S]),le=t(null),q=e(()=>{H===null||le.current===H||(le.current=H,N())},[H,N]),ue=e(e=>{k(e),d(new Set),p(new Set),g(new Map),v(null)},[]),J=u.size;return r(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[c(`div`,{className:`absolute inset-0 bg-black/60`,onClick:a}),r(`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:[r(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[r(`div`,{className:`min-w-0`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:o(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),c(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:o(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),r(`div`,{className:`flex items-center gap-3 shrink-0`,children:[b&&r(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[c(`input`,{type:`checkbox`,checked:S,onChange:e=>te(e.target.checked),className:`accent-primary`}),o(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),c(`button`,{onClick:a,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Close`,children:c(be,{className:`h-4 w-4`})})]})]}),r(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[(L??B??R)&&z.length===0&&c(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 shrink-0`,children:r(`div`,{className:`flex items-start gap-2`,children:[c(Y,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),r(`div`,{className:`min-w-0`,children:[c(`p`,{className:`text-xs font-medium text-destructive`,children:o(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),c(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:L??B??R})]})]})}),T.length>1&&c(Fe,{filters:T,activeFilter:D,onSelect:ue}),c(`div`,{className:`flex-1 min-h-0`,children:c(ie,{mode:`generic`,items:z,pageSize:Ne,getKey:e=>e.childNativeId,getSearchText:Ae,getFilterType:e=>e.type,filterOptions:x(),filterLabel:o(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:M.isLoading||I&&z.length===0,searchPlaceholder:o(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(L??B??R)&&z.length===0?``:o(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:r(`button`,{type:`button`,onClick:re,disabled:I,title:o(`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:[c(G,{className:`h-3.5 w-3.5 ${I?`animate-spin`:``}`}),o(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:o(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>c(Ie,{candidate:e,expandable:!A,expanded:f.has(e.childNativeId),onToggleExpand:()=>W(e.childNativeId),adoptedLabel:o(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:o(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:e=>{let t=y(e.type),n=t.icon;return r(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[c(n,{className:`h-3.5 w-3.5 shrink-0`}),t.label]})}},{key:`select`,header:``,headerClassName:`w-[15%] text-right`,cellClassName:`text-right`,cell:e=>c(`div`,{className:`flex items-center justify-end`,children:c(`button`,{onClick:()=>U(e),disabled:e.alreadyAdopted,"aria-label":u.has(e.childNativeId)?`Deselect`:`Select`,className:`inline-flex h-5 w-5 items-center justify-center rounded border ${u.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:u.has(e.childNativeId)&&c(Se,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!A&&f.has(e.childNativeId),renderExpanded:A?void 0:e=>c(Le,{candidate:e,hiddenChildIds:h.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>oe(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:u.has(e.childNativeId)?`bg-primary/5`:``})})]}),_&&c(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:r(`div`,{className:`flex items-start gap-2`,children:[c(Y,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),c(`p`,{className:`text-[11px] text-destructive`,children:_})]})}),H!==null&&c(ke,{addonId:n,integrationId:i,jobId:H,onFinished:q}),r(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[c(`div`,{}),r(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{onClick:a,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.cancel`,{defaultValue:`Cancel`})}),r(`button`,{onClick:ce,disabled:J===0||V.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:[V.isPending&&c(K,{className:`h-3.5 w-3.5 animate-spin`}),o(`integrations.addSelected`,{defaultValue:`Add selected`}),J>0?` (${J})`:``]})]})]})]})]})}function Fe({filters:e,activeFilter:t,onSelect:n}){return c(`div`,{role:`tablist`,"aria-label":`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 c(`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 Ie({candidate:e,expandable:t,expanded:n,onToggleExpand:i,adoptedLabel:a}){let o=(e.children??[]).length;return r(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[t&&o>0?r(`button`,{type:`button`,onClick:i,"aria-label":n?`Collapse`:`Expand`,"aria-expanded":n,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:[c(n?fe:q,{className:`h-3.5 w-3.5`}),o]}):c(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-subtle/40`,children:`—`}),c(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.name}),e.alreadyAdopted&&c(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:a})]})}function Le({candidate:e,hiddenChildIds:t,onToggleChildHidden:n}){let i=e.children??[];return i.length===0?null:c(`div`,{className:`space-y-1 py-1`,children:i.map(e=>{let i=t.has(e.childNativeId),a=e.capabilities??[];return r(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${i?`opacity-50`:``}`,children:[c(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:e.name}),a.length>0&&c(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:a.join(`, `)}),c(`button`,{onClick:()=>n(e.childNativeId),"aria-label":i?`Show child`:`Hide child`,title:i?`Show after adopt`:`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:c(i?le:_e,{className:`h-3 w-3`})})]},e.childNativeId)})})}n();function Re(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...Re(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function ze(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>Re(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function Be(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 Ve({integrationId:e,addonId:t,name:n,kind:a,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=xe(),m=o(),{data:h,isLoading:g}=I({id:e},{enabled:s===`account`||s===`broker`}),_=i(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:y}=A({addonId:t,nodeId:`hub`},{enabled:s===`account`}),ee=i(()=>v?Be(v):null,[v]),b=P(),x=t=>{b.mutate({id:e,settings:t},{onSuccess:()=>{m.invalidateQueries(),f()}})};return c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,onClick:f,children:r(`div`,{className:`max-h-[85vh] w-full max-w-lg overflow-y-auto rounded-xl border border-border bg-surface p-5 shadow-xl`,onClick:e=>e.stopPropagation(),children:[r(`div`,{className:`mb-3 flex items-center justify-between`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,n]}),c(`button`,{onClick:f,className:`rounded-md p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":p(`common.close`,{defaultValue:`Close`}),children:c(be,{className:`h-4 w-4`})})]}),s===`broker`?l?r(`div`,{className:`space-y-3`,children:[c(`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.`})}),_&&r(`p`,{className:`text-[11px] text-foreground`,children:[p(`integrations.currentBroker`,{defaultValue:`Current broker`}),`:`,` `,c(`span`,{className:`font-mono text-foreground-subtle`,children:_})]}),b.isPending?r(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[c(K,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):c(W,{kind:l,onResolved:e=>{x({brokerId:e})},onBack:f}),b.isError&&c(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.relinkFailed`,{defaultValue:`Failed to update broker link.`})})]}):c(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.noBrokerKind`,{defaultValue:`This integration declares device-adoption but its addon manifest has no brokerKind.`})}):s===`account`?g||y?r(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[c(K,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):c(U,{addonId:t,configSchema:ee,canTest:u,initialName:n,initialConfig:ze(ee,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e})=>x(e),onBack:f}):c(T,{trpc:d,addonId:t,nodeId:`hub`,title:n})]})})}n();function He(){let{t}=xe(),{integrationId:n}=he(),d=o(),m=ue(),[g,_]=me(),y=u(),[x,S]=s(!1),[C,w]=s(!1),[T,O]=s(!1),[P,F]=s(!1),[I,L]=s(!1),{data:R,isLoading:B}=k({id:n??``},{enabled:!!n}),{data:V}=A({addonId:R?.addonId??``,nodeId:`hub`},{enabled:!!R?.addonId}),{data:U,isSuccess:W}=E(),G=i(()=>{let e=R?.addonId;return!e||!W?null:(U??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[U,R?.addonId,W]),{data:ce}=N({}),le=i(()=>(ce?.providers??[]).some(e=>e.addonId===R?.addonId),[ce,R?.addonId]),q=G!==null,J=R?.info?.fixed===!0,de=q?G===`device-adoption`?t(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):t(`integrations.addDevice`):t(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),fe=i(()=>{let e=R?.addonId;return!e||!W?null:(U??[]).find(t=>t.addonId===e)?.brokerKind??null},[U,R?.addonId,W]),_e=i(()=>{let e=R?.addonId;return!e||!W?!1:(U??[]).find(t=>t.addonId===e)?.canTest===!0},[U,R?.addonId,W]),Se=i(()=>{let e=R?.addonId;return!e||!W?null:(U??[]).find(t=>t.addonId===e)?.mode??null},[U,R?.addonId,W]);l(()=>{g.get(`add`)===`1`&&q&&(S(!0),_(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[g,q,_]);let we=V!=null&&Array.isArray(V.sections)&&V.sections.some(e=>e.fields.length>0),{data:Te}=f({projection:`slim`},{staleTime:3e4,refetchInterval:3e4}),X=[[`integrations`,`get`],{input:{id:n??``},type:`query`}],Z=p({onMutate:async e=>{await d.cancelQueries({queryKey:X});let t=d.getQueryData(X);return t!=null&&d.setQueryData(X,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&d.setQueryData(X,r.previous)},onSettled:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=j({onSuccess:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]}),F(!1),m(`/integrations`)}}),Ee=M({onSuccess:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Oe=v({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ke=h({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ae=b({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),$=i(()=>Te??[],[Te]),je=i(()=>{let e=new Map;for(let t of $)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[$]),Me=e(e=>je.get(e)??null,[je]),Ne=e(e=>c(z,{type:e,size:`sm`}),[]),Fe=e(e=>m(`/devices/${String(e)}`),[m]),Ie=i(()=>{let e=R?.addonId;return e?$.filter(t=>t.addonId===e):[]},[$,R?.addonId]),Le=i(()=>te(Ie).length,[Ie]);return B?r(`div`,{className:`p-4`,children:[c(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),c(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]}):R?r(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[c(D,{items:[{label:`Integrations`,onClick:()=>m(`/integrations`)},{label:R.name}]}),r(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[r(`div`,{className:`flex items-center gap-3 min-w-0`,children:[c(`img`,{src:`/api/addon-assets/${R.addonId}/assets/icon.svg`,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:e=>{e.target.style.display=`none`}}),r(`div`,{className:`min-w-0`,children:[c(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:R.name}),r(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[R.addonId,` · `,Le,` `,t(`integrations.devices`)]})]})]}),r(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[le&&r(`button`,{onClick:()=>w(!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:`Scan the network for devices (incl. a different subnet)`,children:[c(ae,{className:`h-3.5 w-3.5`}),`Scan network`]}),!J&&r(`button`,{onClick:()=>S(!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:de,children:[c(H,{className:`h-3.5 w-3.5`}),de]}),r(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Z.isPending?`opacity-60`:``} ${R.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:t(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[c(ne,{checked:R.enabled,onCheckedChange:e=>Z.mutate({id:n,enabled:e}),disabled:Z.isPending,"aria-label":R.enabled?`Disable integration`:`Enable integration`}),c(`span`,{className:`text-[11px] font-medium ${R.enabled?`text-success`:`text-foreground-subtle`}`,children:R.enabled?`Enabled`:`Disabled`}),Z.isPending&&c(K,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),Se!==`standalone`&&(we||G===`device-adoption`)&&r(`button`,{onClick:()=>O(!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:[c(ge,{className:`h-3 w-3`}),t(`integrations.config`)]}),r(`button`,{onClick:()=>L(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.logs`,{defaultValue:`View logs`}),children:[c(ve,{className:`h-3 w-3`}),t(`integrations.logs`,{defaultValue:`Logs`})]}),c(re,{label:`Restart`,icon:se,title:`Restart "${R.name}"?`,description:`Restarting the addon will briefly disconnect every device backed by it (${Le} active). Streams will reconnect automatically.`,confirmLabel:`Restart`,triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ee.isPending,action:()=>Ee.mutateAsync({addonId:R.addonId})}),!J&&r(`button`,{onClick:()=>F(!0),className:`flex items-center gap-1.5 rounded-lg border border-danger bg-danger/10 px-3 py-1.5 text-[11px] font-medium text-danger hover:bg-danger hover:text-background transition-colors`,title:t(`integrations.delete`,{defaultValue:`Delete integration`}),children:[c(ye,{className:`h-3 w-3`}),t(`integrations.delete`,{defaultValue:`Delete`})]})]})]}),c(ie,{context:`integration-detail`,devices:$,trpc:y.trpcClient,defaultView:`cards`,forceAddon:R.addonId,urlScope:`root`,lsKey:`integration-detail:${R.addonId}`,resolveIntegrationIcon:Ne,resolveParent:Me,onNavigate:Fe,batchActions:{remove:Oe.mutate,disable:ke.mutate,enable:Ae.mutate},...J?{}:{onDeleteDevice:e=>Oe.mutate({deviceId:e.id})}}),x&&n&&G===`device-adoption`&&c(Pe,{addonId:R.addonId,integrationId:n,onClose:()=>S(!1)}),x&&n&&G===`device-provider`&&c(De,{open:x,integrationId:n,addonId:R.addonId,onClose:()=>S(!1)}),C&&R&&c(oe,{open:C,scope:{addonId:R.addonId,label:R.name},onClose:()=>w(!1)}),T&&n&&G!==null&&Se!==null&&c(Ve,{integrationId:n,addonId:R.addonId,name:R.name,kind:G,mode:Se,brokerKind:fe,canTest:_e,trpc:y.trpcClient,onClose:()=>O(!1)}),I&&c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6`,onClick:()=>L(!1),children:r(`div`,{className:`flex flex-col rounded-xl border border-border bg-surface shadow-xl w-full max-w-5xl h-[80vh]`,onClick:e=>e.stopPropagation(),children:[r(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2.5`,children:[r(`div`,{className:`flex items-center gap-2 min-w-0`,children:[c(ve,{className:`h-4 w-4 text-primary shrink-0`}),c(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:R.name}),r(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate`,children:[R.addonId,n?` · ${n}`:``]})]}),c(`button`,{onClick:()=>L(!1),className:`flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Close logs`,children:c(be,{className:`h-4 w-4`})})]}),c(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:c(ee,{addonId:R.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})}),P&&c(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,onClick:()=>!Q.isPending&&F(!1),children:r(`div`,{className:`rounded-xl border border-border bg-background p-5 shadow-2xl w-96 space-y-3`,onClick:e=>e.stopPropagation(),children:[r(`div`,{className:`flex items-start gap-3`,children:[c(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg bg-danger/10 shrink-0`,children:c(Y,{className:`h-4 w-4 text-danger`})}),r(`div`,{className:`min-w-0`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`integrations.deleteTitle`,{defaultValue:`Delete integration?`})}),c(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:R.name,count:Le})})]})]}),Q.error&&c(`div`,{className:`rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:Q.error instanceof Error?Q.error.message:String(Q.error)}),r(`div`,{className:`flex items-center justify-end gap-2 pt-1`,children:[c(`button`,{onClick:()=>F(!1),disabled:Q.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:t(`integrations.cancel`,{defaultValue:`Cancel`})}),c(`button`,{onClick:()=>Q.mutate({id:n}),disabled:Q.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-danger px-3 py-1.5 text-[11px] font-medium text-background hover:bg-danger/90 transition-colors disabled:opacity-60 disabled:cursor-not-allowed`,children:Q.isPending?r(a,{children:[c(K,{className:`h-3 w-3 animate-spin`}),t(`integrations.deleting`,{defaultValue:`Deleting…`})]}):r(a,{children:[c(ye,{className:`h-3 w-3`}),t(`integrations.confirmDelete`,{defaultValue:`Delete integration`})]})})]})]})})]}):r(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[c(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:c(Ce,{className:`h-6 w-6 text-foreground-subtle`})}),r(`div`,{className:`space-y-1 max-w-sm`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),c(`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:n??``})})]}),r(`button`,{onClick:()=>m(`/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:[c(pe,{className:`h-3 w-3`}),t(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}export{He as IntegrationDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as s}from"./player-overlays-wniETo4u.js";import{C as c,En as l,_r as u,ar as d,cr as f,dr as p,fr as m,ir as ee,ln as h,lr as g,sr as _,ur as v}from"./src-IW6snE8b.js";import{H as y,dt as b,st as x}from"./src-CsxD-27Y.js";import{t as S}from"./pencil-D-rxGNNf.js";import{t as te}from"./plus-BVcSfMMt.js";import{t as C}from"./radio-dB0UNm47.js";import{t as w}from"./wifi-DPLmik5h.js";import{C as T,J as E,K as D,o as O,r as k,v as A}from"./index-Cp84SBzW.js";import{t as j}from"./AdminPage-CCD07UMs.js";import{t as M}from"./AdminTabs-DIHki8py.js";import{t as N}from"./BrokerForm-mfcucCqe.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";import{t as F}from"./AddonCollectionPage-CAMY7BSp.js";var I=D(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),L=D(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]);e();var R={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function z(e){return R[e]??e}function B(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var V={connected:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,connecting:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function H({status:e}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${V[e]}`,children:e})}function U(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function W({title:e,subtitle:n,onClose:r,children:i}){return P(),o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[t(`div`,{className:`space-y-0.5`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),n&&o(`p`,{className:`text-xs text-foreground-subtle`,children:n})]}),o(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-4 w-4`})})]}),o(`div`,{className:`p-4 max-h-[70vh] overflow-y-auto overscroll-contain`,children:i})]})})}function G({kinds:e,onClose:n,onDone:s}){let c=i(),l=e=>`${e.addonId??``}::${e.kind}`,[u,d]=a(e[0]?l(e[0]):``),[f,p]=a(``),[m,h]=a(!1),[g,_]=a(``),v=e.find(e=>l(e)===u)??e[0],y=v?.kind??``,b=v?.addonId,x=ee({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]}),s()}}),S=e=>{if(!y||f.trim().length===0)return;let t=m?g.trim():``;m&&t===``||x.mutate({kind:y,name:f.trim(),settings:e,...t===``?{}:{id:t},...b===void 0?{}:{addonId:b}})};return o(W,{title:`Add broker`,subtitle:`Register a message broker for exporters and automations.`,onClose:x.isPending?()=>{}:n,children:t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Kind`}),o(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:e.map(e=>o(`option`,{value:l(e),children:e.label},l(e)))})]}),t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Name`}),o(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`My Home Assistant`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),t(`div`,{className:`space-y-1 rounded border border-border px-3 py-2`,children:[t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[o(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),`Restore a broker that was removed, under its original id`]}),m&&t(r,{children:[o(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`ha_004`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Devices remember the broker id they were discovered under, so restoring the original id reconnects them instead of needing re-discovery. An id that is still in use is refused.`})]})]}),x.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:x.error instanceof Error?x.error.message:String(x.error)}),y&&o(N,{kind:y,...b===void 0?{}:{addonId:b},onSubmit:S,onCancel:n,submitLabel:x.isPending?`Adding…`:`Add broker`,disabled:x.isPending}),f.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter a name before saving.`}),m&&g.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter the original id, or clear the checkbox to create a new broker.`})]})})}function K({broker:e,onClose:r,onDone:a}){let s=i(),c=d({id:e.id,addonId:e.addonId}),l=p({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),a()}}),u=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return o(W,{title:`Edit ${e.name}`,subtitle:`${z(e.kind)} · ${e.id}`,onClose:l.isPending?()=>{}:r,children:c.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(T,{className:`h-3.5 w-3.5 animate-spin`}),` Loading settings…`]}):c.isError?t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load settings:`,` `,c.error instanceof Error?c.error.message:`Unknown error`]}),o(`div`,{className:`flex justify-end`,children:o(`button`,{type:`button`,onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Close`})})]}):t(`div`,{className:`space-y-3`,children:[l.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:l.error instanceof Error?l.error.message:String(l.error)}),o(N,{kind:e.kind,addonId:e.addonId,initialValues:u,onSubmit:t=>{l.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:r,submitLabel:l.isPending?`Saving…`:`Save`,disabled:l.isPending})]})})}function q({broker:e,onEdit:n}){let r=i(),s=h(),[c,l]=a(null),u=m({onSuccess:e=>l(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>l({ok:!1,error:e instanceof Error?e.message:String(e)})}),d=v({onSuccess:()=>{r.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),f=async()=>{await s({title:`Delete broker`,message:`Delete broker "${e.name}"? Integrations that depend on it will stop working.`,confirmLabel:`Delete`,variant:`danger`})&&d.mutate({id:e.id,addonId:e.addonId})};return t(`tr`,{className:`border-b border-border last:border-0`,children:[o(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:e.name}),o(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:z(e.kind)}),t(`td`,{className:`px-3 py-2`,children:[o(H,{status:e.status}),c&&o(`span`,{className:`ml-2 text-[10px] ${c.ok?`text-success`:`text-danger`}`,children:c.ok?`OK`:c.error??`failed`})]}),o(`td`,{className:`px-3 py-2`,children:t(`div`,{className:`flex items-center justify-end gap-1.5`,children:[t(`button`,{type:`button`,onClick:()=>u.mutate({id:e.id,addonId:e.addonId}),disabled:u.isPending,title:`Test connection`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10 disabled:opacity-50`,children:[u.isPending?o(T,{className:`h-3 w-3 animate-spin`}):o(w,{className:`h-3 w-3`}),`Test`]}),t(`button`,{type:`button`,onClick:()=>n(e),title:`Edit`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10`,children:[o(S,{className:`h-3 w-3`}),` Edit`]}),t(`button`,{type:`button`,onClick:()=>{f()},disabled:d.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded border border-danger/40 px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?o(T,{className:`h-3 w-3 animate-spin`}):o(O,{className:`h-3 w-3`}),`Delete`]})]})})]})}function J(){let e=f({}),r=g(),i=n(()=>U(e.data),[e.data]),[s,c]=a(!1),[l,u]=a(null),d=n(()=>{let e=new Map;for(let t of B(r.data))for(let n of t.kinds)e.set(`${t.addonId}::${n.kind}`,{addonId:t.addonId,kind:n.kind,label:n.label});for(let t of i)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:z(t.kind)});return[...e.values()]},[i,r.data]);return t(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex items-center justify-end`,children:t(`button`,{type:`button`,onClick:()=>c(!0),disabled:d.length===0,title:d.length===0?`No broker providers available`:void 0,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:[o(te,{className:`h-3.5 w-3.5`}),` Add broker`]})}),o(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[o(`thead`,{children:t(`tr`,{className:`border-b border-border bg-background/50`,children:[o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Name`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Kind`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Status`}),o(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Actions`})]})}),t(`tbody`,{children:[e.isLoading&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[o(T,{className:`inline h-4 w-4 animate-spin`}),` Loading brokers…`]})}),e.isError&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[`Failed to load brokers:`,` `,e.error instanceof Error?e.error.message:`Unknown error`]})}),!e.isLoading&&!e.isError&&i.length===0&&o(`tr`,{children:o(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:`No brokers registered yet. Add one to publish device events for downstream automations.`})}),i.map(e=>o(q,{broker:e,onEdit:u},e.id))]})]})}),s&&o(G,{kinds:d,onClose:()=>c(!1),onDone:()=>c(!1)}),l&&o(K,{broker:l,onClose:()=>u(null),onDone:()=>u(null)})]})}var Y=[{kind:`device-export`,tabId:`device-export`,title:`Device export`,subtitle:`Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).`,icon:L,emptyTitle:`No device-export providers installed`,emptyDescription:`Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …`,addLabel:`Add export`},{kind:`email`,tabId:`email`,title:`Email providers`,subtitle:`Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).`,icon:I,emptyTitle:`No email providers installed`,emptyDescription:`Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.`,addLabel:`Add email provider`},{kind:`broker`,tabId:`broker`,title:`Brokers`,subtitle:`Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).`,icon:C,emptyTitle:`No brokers installed`,emptyDescription:`Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.`,addLabel:`Add broker`}];function X(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e.name;if(typeof t==`string`)return t}return null}function Z(e){let t=e,n=t?.manifest;if(!n?.id)return null;let r=[];for(let e of n.capabilities??[]){let t=X(e);t!==null&&r.push(t)}let i=n.packageDisplayName??n.name??n.id,a=t?.process?.state??null;return{addonId:n.id,displayName:i,isActive:a===`running`,packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:r,processState:a}}function Q(e,t){let n=new Set(t);return e.filter(e=>e.capNames.some(e=>n.has(e)))}function ne(e){for(let[t,n]of Object.entries(y))if(n===e)return t;return null}function re(e){return e===`running`?{label:`Running`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`}:e===`crashed`||e===`failed`?{label:e===`failed`?`Failed`:`Crashed`,className:`bg-danger/15 text-danger`}:e===`stopped`||e===`disabled`?{label:`Stopped`,className:`bg-foreground-subtle/15 text-foreground-subtle`}:{label:e??`Unknown`,className:`bg-foreground-subtle/15 text-foreground-subtle`}}function $({label:e,className:t}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function ie({addonId:e}){let{data:t,isLoading:n}=_({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=b.safeParse(t);if(!r.success)return null;let i=r.data;return o($,{label:`${i.brokerCount} broker${i.brokerCount===1?``:`s`}${i.connectedCount>0?` • ${i.connectedCount} connected`:``}`,className:`bg-primary/10 text-primary`})}function ae({addonId:e}){let{data:t,isLoading:n}=u({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=x.safeParse(t);if(!r.success)return null;let i=r.data,a=i.linkState===`linked`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i.linkState===`error`?`bg-danger/15 text-danger`:`bg-foreground-subtle/15 text-foreground-subtle`;return o($,{label:`${i.linkState} • ${i.exposedDeviceCount} exposed`,className:a})}function oe({kind:e,addonId:t}){return e===`broker`?o(ie,{addonId:t}):e===`device-export`?o(ae,{addonId:t}):null}function se({descriptor:e,rows:n,isLoading:i}){let a=ne(e.kind),l=e.kind===`device-export`,u=s(),d=E();return o(F,{title:e.title,subtitle:e.subtitle,pageIcon:e.icon,itemIcon:e.icon,capability:a??e.kind,installButtonLabel:e.addLabel,items:n,isLoading:i,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription,renderStatusBadges:n=>{let i=re(n.processState);return t(r,{children:[o($,{label:i.label,className:i.className}),o(oe,{kind:e.kind,addonId:n.addonId})]})},renderExpandedPanel:l?e=>o(c,{addonId:e.addonId,trpc:u.trpcClient,onOpenDevice:e=>d(`/devices/${e}`)}):void 0,showChrome:!0})}function ce(){let e=l(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(Z).filter(e=>e!==null);return o(j,{icon:A,title:`External systems`,subtitle:`External systems this hub talks to — device exporters, email relays, and message brokers. Settings, Logs and Events are docked under every provider.`,children:o(M,{tabs:Y.map(n=>{let r=Object.entries(y).filter(([,e])=>e===n.kind).map(([e])=>e),i=n.kind===`broker`?o(J,{}):o(se,{descriptor:n,rows:Q(t,r),isLoading:e.isLoading});return{id:n.tabId,label:n.title,icon:n.icon,content:i}})})})}export{ce as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as l}from"./player-overlays-wniETo4u.js";import{Br as u,T as d,_i as f,bi as p,en as m,gn as ee,i as h,kr as g,mi as te,vr as ne,w as _}from"./src-IW6snE8b.js";import{t as v}from"./ProviderIcon-BuQT-C1f.js";import{t as y}from"./plus-BVcSfMMt.js";import{i as b,n as re,r as x,t as S}from"./ScanNetworkModal-DO_NYOIO.js";import{t as C}from"./refresh-cw-srKCTv_-.js";import{C as ie,I as w,J as T,R as E,V as D,X as O,f as k,r as A,t as j,v as M,z as N}from"./index-Cp84SBzW.js";import{t as ae}from"./AdminPage-CCD07UMs.js";import"./useEventInvalidation-CsNvM4qI.js";import{t as P}from"./StatusBadge-CeptlsPG.js";import{t as F}from"./useBodyScrollLock-BDocajQE.js";t();function I(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function L({providerId:e,onImport:t,onSkip:r}){let{t:i}=j(),[a,l]=o(new Set),u=g(),d=u.data,f=u.isPending||!u.data&&!u.isError;c(()=>{e&&(u.isPending||u.data||u.mutate({addonId:e}))},[e,u]);function p(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(f)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let m=d??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:m.length>0?i(`integrations.foundDevices`,{count:m.length}):i(`integrations.noDevicesFound`)}),m.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:m.map(e=>{let t=e.stableId,r=e.suggestedName??t,i=a.has(t);return n(`button`,{onClick:()=>p(t),className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${i?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${i?`border-primary bg-primary`:`border-border`}`,children:i&&s(N,{className:`h-3 w-3 text-primary-foreground`})}),s(D,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`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:i(`integrations.skip`)}),m.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.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:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}function R({onSelect:e,onClose:t,pendingAddonId:r=null}){let{t:i}=j(),a=T(),{data:o,isLoading:c}=f();if(c)return s(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-14 rounded-lg bg-surface animate-pulse`},e))});let l=r!==null;return n(`div`,{className:`space-y-2`,children:[(o??[]).map(o=>{let c=o.instanceMode===`unique`&&o.existingInstances.length>0,u=r===o.addonId,d=l;return n(`button`,{disabled:d,onClick:()=>{if(!d)if(c){let e=o.existingInstances[0].id;t(),a(`/integrations/${e}`)}else e(o.addonId,o.instanceMode,o.discoveryMode,o.name,o.kind,o.brokerKind,o.mode,o.canTest)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[o.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`img`,{src:o.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`span`,{className:`text-sm`,style:{color:o.color},children:`◉`})}),n(`div`,{className:`flex-1 min-w-0`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:o.name}),o.description&&s(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,children:o.description})]}),u?s(ie,{className:`h-4 w-4 animate-spin text-primary flex-shrink-0`}):c?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(k,{className:`h-3 w-3`}),i(`integrations.manage`)]}):s(w,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},o.addonId)}),(o??[]).length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:i(`integrations.noProviders`)})]})}t();function oe(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 z=2e4;function se({open:e,onClose:t}){let{t:l}=j(),u=T(),d=a(),[f,p]=o(`picker`),[m,h]=o(null),[_,v]=o(null),[y,b]=o(`manual`),[S,C]=o(null),[w,E]=o(``),[D,O]=o(null),[k,M]=o(null),[N,ae]=o(!1),{data:P}=ee({addonId:m??``,nodeId:`hub`},{enabled:m!=null}),se=r(()=>P?oe(P):null,[P]),B=te({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),V=g(),ce=V.data;c(()=>{f!==`discovery`||!_||!m||V.isPending||V.data||V.mutate({addonId:m})},[f,_,m,V]);let H=ne({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function U(e,t,n,r,i,a,o,s){if(!B.isPending){if(h(e),ae(s),b(n),E(r),M(null),o===`broker`){if(!a){M(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),p(`broker`);return}if(o===`account`){p(`config`);return}W(e,r)}}async function W(e,n){try{let r=await B.mutateAsync({addonId:e,name:n,settings:{}});t(),J(),u(`/integrations/${r.id}?add=1`)}catch{}}async function G(e){if(m)try{let t=await B.mutateAsync({addonId:m,name:e.name,settings:e.config});v(t.id),y===`auto`||y===`both`?p(`discovery`):q(t.id)}catch{}}async function K(e){if(m)try{let t=await B.mutateAsync({addonId:m,name:w,settings:{brokerId:e}});O(t.id),v(t.id),q(t.id)}catch{}}async function le(e){if(m){for(let t of e){let e=ce?.find(e=>e.stableId===t);e&&await H.mutateAsync({addonId:m,candidate:e,...D===null?{}:{integrationId:D}})}q()}}function q(e){let n=e??_??m;t(),J(),n&&u(`/integrations/${n}`)}function J(){p(`picker`),h(null),v(null),b(`manual`),C(null),E(``),O(null),M(null),ae(!1)}function Y(){t(),J()}F(e);let X=B.isPending,Z=I(X,z);if(!e)return null;let Q={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ue=X?m:null,$=B.error,de=X&&!Z;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:Y}),n(`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:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:Q[f]}),s(`button`,{onClick:Y,disabled:de,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:s(A,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!X&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),f===`picker`&&n(i,{children:[k&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:k}),s(R,{onSelect:U,onClose:Y,pendingAddonId:ue})]}),f===`config`&&m&&s(re,{addonId:m,configSchema:se??null,canTest:N,onSave:G,onBack:()=>p(`picker`)}),f===`broker`&&S&&s(x,{kind:S,onResolved:e=>{K(e)},onBack:()=>p(`picker`)}),f===`discovery`&&_&&s(L,{providerId:_,onImport:le,onSkip:q})]}),X&&n(`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:[s(ie,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Z&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Z&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:Y,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:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function B({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,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:s(t?E:w,{className:`h-3.5 w-3.5`})}),s(v,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function V(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(B,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(P,{status:e.status})}]}t();function ce(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var H=`expand`;function U(){let{t}=j(),a=T(),c=l(),[f]=O(),[ee,g]=o(!1),te=e(()=>g(!0),[]),ne=e(()=>g(!1),[]),[re,x]=o(!1),ie=e(()=>x(!0),[]),w=e(()=>x(!1),[]);h([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),h([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:E,isLoading:D,refetch:k}=p(void 0),{data:A,isLoading:N,refetch:P}=u({projection:`slim`},{staleTime:3e4}),F=r(()=>A??[],[A]),I=r(()=>E??[],[E]),L=r(()=>{let e=new Map;for(let t of F)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[F]),R=r(()=>{let e=new Map;for(let t of d(F)){let n=t.addonId??``;n&&e.set(n,(e.get(n)??0)+1)}return e},[F]),oe=r(()=>I.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:ce(e),deviceCount:R.get(e.addonId)??0})),[I,R]),z=f.get(H),B=e(e=>{let t=new URLSearchParams(window.location.search);t.get(H)===e?t.delete(H):t.set(H,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`))},[]),U=e(e=>a(`/integrations/${e.id}`),[a]),W=e(e=>L.get(e)??null,[L]),G=e(e=>s(v,{type:e,size:`sm`}),[]),K=e(e=>a(`/devices/${String(e)}`),[a]),le=e(e=>s(_,{context:`integration-detail`,devices:F,trpc:c.trpcClient,forceAddon:e.addonId,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:G,resolveParent:W,onNavigate:K}),[F,c.trpcClient,G,W,K]),q=e(e=>z===e.addonId,[z]),J=r(()=>V({isExpanded:q,onToggleExpand:B}),[q,B]),Y=e(e=>`${e.name} ${e.addonId}`,[]),X=e(e=>e.addonId,[]),Z=e(()=>{k(),P()},[k,P]),Q=D||N,ue=I.length>0;return n(ae,{icon:M,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:Z,disabled:Q,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:`Refresh`,children:s(C,{className:m(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),n(`button`,{onClick:ie,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:`Scan the local network for devices`,children:[s(b,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:te,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:[s(y,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Q&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!ue&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Q&&ue&&s(_,{mode:`generic`,items:oe,getKey:X,getSearchText:Y,columns:J,onRowClick:U,isExpanded:q,renderExpanded:le,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(se,{open:ee,onClose:ne}),s(S,{open:re,onClose:w})]})}export{U as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as l}from"./player-overlays-wniETo4u.js";import{Ai as u,Bi as d,Di as f,Dn as p,En as m,Fi as h,Ft as g,Hi as _,Ii as v,It as y,Ji as b,Li as x,Lt as S,Mi as ee,Mt as C,Ni as w,Oi as te,Pi as ne,Ri as re,Ui as T,Vi as E,Wi as ie,Yi as ae,Yt as oe,et as D,gs as O,ji as se,ki as ce,nt as k,qi as A,zi as j}from"./src-IW6snE8b.js";import{at as M,et as N}from"./src-CsxD-27Y.js";import{t as P}from"./boxes-BqAi_ZYu.js";import{t as F}from"./copy-D25tAWbr.js";import{t as I}from"./play-s0iikQHY.js";import{t as le}from"./refresh-cw-srKCTv_-.js";import{t as ue}from"./rotate-ccw-CY-1yf9N.js";import{t as L}from"./server-BQtqKhWd.js";import{t as R}from"./shield-Df5MsuC2.js";import{t as z}from"./square-CFDIb2ZA.js";import{t as B}from"./wifi-DPLmik5h.js";import{C as V,E as H,K as U,S as W,a as G,c as de,j as K,r as fe,x as pe,y as q,z as me}from"./index-Cp84SBzW.js";import{t as he}from"./AdminPage-CCD07UMs.js";import{t as ge}from"./AdminTabs-DIHki8py.js";import{t as _e}from"./NodeAddonsSettingsPanel-CAyKEQpD.js";import{t as J}from"./AddonCollectionPage-CAMY7BSp.js";import{t as Y}from"./addon-display-names-DvSEQty-.js";var ve=U(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),ye=U(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),be=U(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]);t();var X=5e3,xe={connected:!1,endpoint:null};function Se(){let e=a(),t=p({capName:`network-access`},{refetchInterval:X}),n=m(void 0,{refetchInterval:X}),i=r(()=>Y(n.data??[]),[n.data]),c=r(()=>(t.data??[]).map(e=>({addonId:e.addonId,displayName:i.get(e.addonId)??e.addonId,isActive:e.isActive})),[t.data,i]),[l,u]=o(null),[d,f]=o({}),h=(t,n)=>{let r=n?.addonId;e.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),u(null),f(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},g=(e,t)=>{u(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);f(e=>({...e,[n]:r}))},_=b({onSuccess:h,onError:g}),v=ae({onSuccess:h,onError:g});return s(J,{title:`Remote Access`,subtitle:`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …). Settings, Logs and Events are docked under every provider.`,pageIcon:H,itemIcon:H,capability:`network-access`,installButtonLabel:`Add tunnel`,items:c,isLoading:t.isLoading,emptyTitle:`No remote-access providers installed`,emptyDescription:`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`,renderStatusBadges:e=>s(we,{addonId:e.addonId}),itemError:e=>d[e.addonId]??null,renderPrimaryAction:e=>s(Te,{addonId:e.addonId,busyId:l,onStart:e=>{u(e),_.mutate({addonId:e})},onStop:e=>{u(e),v.mutate({addonId:e})}})})}function Ce(e){let{data:t}=A({addonId:e},{refetchInterval:X,retry:!1}),n=t?M.safeParse(t):null;return n?.success?n.data:xe}function we({addonId:e}){let t=Ce(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.connected?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.connected?`Connected`:`Disconnected`}),t.endpoint&&n(`a`,{href:t.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-[10px] text-emerald-700 dark:text-emerald-300 hover:underline flex items-center gap-1`,children:[s(K,{className:`h-3 w-3`}),t.endpoint.url]})]})}function Te({addonId:e,busyId:t,onStart:r,onStop:i}){let a=Ce(e),o=t===e;return a.connected?n(S,{size:`sm`,variant:`secondary`,disabled:o,onClick:()=>i(e),children:[o?s(V,{className:`h-3 w-3 animate-spin`}):s(z,{className:`h-3 w-3`}),`Stop`]}):n(S,{size:`sm`,variant:`primary`,disabled:o,onClick:()=>r(e),children:[o?s(V,{className:`h-3 w-3 animate-spin`}):s(I,{className:`h-3 w-3`}),`Start`]})}t();var Ee=3e4;function De(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Oe(){let e=p({capName:`turn-provider`},{refetchInterval:Ee}),t=m(void 0,{refetchInterval:Ee}),i=O(),a=i.data??[],o=r(()=>Y(t.data??[]),[t.data]);return s(J,{title:`TURN Servers`,subtitle:`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`,pageIcon:q,itemIcon:q,capability:`turn-provider`,installButtonLabel:`Add provider`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:o.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,o]),isLoading:e.isLoading,emptyTitle:`No TURN providers installed`,emptyDescription:`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`,renderExpandedPanel:e=>s(ke,{addonId:e.addonId,enabled:e.isActive}),trailing:n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Combined ICE server list`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`What the WebRTC layer fetches per-session.`})]}),s(S,{size:`sm`,variant:`secondary`,onClick:()=>i.refetch(),disabled:i.isFetching,children:`Refresh`})]}),s(`div`,{className:`p-4`,children:a.length===0?s(`div`,{className:`text-xs text-foreground-subtle`,children:`No servers from enabled providers.`}):s(`div`,{className:`flex flex-col gap-3`,children:a.map((e,t)=>{let r=Array.isArray(e.urls)?e.urls:[e.urls];return n(`div`,{className:`rounded border border-border bg-surface`,children:[(e.username||e.credential)&&n(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[e.username&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,s(`span`,{className:`text-foreground`,children:e.username})]}),e.credential&&n(`span`,{children:[s(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,s(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(e=>s(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},t)})})})]})})}function ke({addonId:e,enabled:t}){let i=O({addonId:e},{enabled:t,retry:!1}),a=r(()=>De(i.data??[]),[i.data]);return!t||a.length===0?null:n(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[n(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Discovered ICE servers (`,a.length,`)`]}),s(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>s(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-mono bg-foreground-subtle/10 text-foreground`,children:e},e))})]})}t();var Ae={lan:q,wifi:B,docker:P,vpn:W,loopback:L,other:L},je={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Me=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function Ne(e){let{interfaces:t,disabled:i,hideLoopback:a,ipv4Only:o,emptyMessage:c}=e,l=r(()=>t.filter(e=>!(a&&e.kind===`loopback`||o&&e.family!==`IPv4`)),[t,a,o]),u=r(()=>{let e=new Map;for(let t of l){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Me.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[l]),d=t=>e.mode===`single`?e.value===t:e.value.includes(t),f=t=>{if(i||t.kind===`loopback`)return;if(e.mode===`single`){e.onChange(e.value===t.address?null:t.address);return}let n=new Set(e.value);n.has(t.address)?n.delete(t.address):n.add(t.address),e.onChange([...n])};return l.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic`,children:c??`No addresses available.`}):s(`div`,{className:`flex flex-col gap-3`,children:u.map(({kind:t,items:r})=>n(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[s(Ae[t]??L,{className:`h-3.5 w-3.5 text-foreground-subtle`}),s(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:je[t]??t}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,r.length]})]}),s(`ul`,{className:`divide-y divide-border`,children:r.map(t=>{let r=d(t.address),a=t.kind===`loopback`,o=!t.plausible&&!a;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 ${a?`opacity-60 cursor-not-allowed`:i?`opacity-60`:o?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>f(t),children:[s(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${e.mode===`single`?`rounded-full`:`rounded`} border ${r?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:r&&s(me,{className:`h-3 w-3`})}),n(`div`,{className:`flex-1 min-w-0 ${o?`text-foreground-subtle`:``}`,children:[n(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`span`,{className:`font-mono text-xs font-semibold ${o?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),s(`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&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:`Auto-preferred`}),a&&s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:`Always included`}),o&&n(`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:[s(G,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]}),n(`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))})}t();var Pe={"lan-ipv4":{label:`IPv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{label:`IPv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{label:`Public`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},loopback:{label:`Loopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function Z(e){return e.kind!==`loopback`}function Fe(e){return e.kind!==`loopback`}function Ie(){let e=a(),t=l(),i=ee(void 0,{refetchInterval:3e4}),u=f(void 0),d=v({onSuccess:()=>{e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),p=ne({onSuccess:t=>{y(t.addresses),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),m=r(()=>i.data?.interfaces??[],[i.data]),h=te({port:typeof window<`u`?Number(window.location.port)||(window.location.protocol===`https:`?443:80):4e3,scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),[_,y]=o([]),[b,w]=o(!1);c(()=>{!b&&u.data&&(y(u.data.addresses),w(!0))},[u.data,b]);let T=u.data?.addresses??[],E=r(()=>{if(_.length!==T.length)return!0;let e=[..._].toSorted(),t=[...T].toSorted();return e.some((e,n)=>e!==t[n])},[_,T]),ie=()=>{d.mutate({addresses:[..._]})},ae=()=>{y(T)},oe=()=>{y([])},O=()=>{i.refetch(),h.refetch(),u.refetch(),A.refetch(),M.refetch()},k=async()=>{try{let e=await t.raceConnectionEndpoints({perCandidateTimeoutMs:1500});console.info(`[network-addresses] race result`,e)}catch(e){console.warn(`[network-addresses] race failed`,e)}},A=ce(),j=x({onSuccess:()=>void A.refetch()}),M=se(),N=re({onSuccess:()=>void M.refetch()}),P=h.data?.endpoints??[],F=A.data?.baseUrl??null,I=A.data?.resolved??null,L=M.data?.baseUrls??[],R=L.length===0,z=F===null,B=e=>R?e.kind===`lan-ipv4`||e.kind===`public`&&e.interfaceKind===`public`:L.includes(e.baseUrl),V=e=>F===null?I===e.baseUrl:F===e.baseUrl,H=e=>{if(!Z(e))return;let t=R?P.filter(e=>Z(e)&&B(e)).map(e=>e.baseUrl):[...L],n=t.includes(e.baseUrl)?t.filter(t=>t!==e.baseUrl):[...t,e.baseUrl];N.mutate({baseUrls:n})},U=e=>{if(Fe(e)){if(V(e)){z||j.mutate({baseUrl:null});return}j.mutate({baseUrl:e.baseUrl})}},W=r(()=>[{key:`url`,header:`Endpoint`,render:e=>n(`div`,{className:`min-w-0 py-0.5`,children:[s(`div`,{className:`font-mono text-[12px] break-all ${e.plausible?`text-foreground`:`text-foreground-subtle`}`,children:e.baseUrl}),n(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[s(`span`,{children:e.label}),e.interfaceKind!==`lan`&&e.interfaceKind!==`public`&&s(`span`,{className:`uppercase tracking-wide`,children:e.interfaceKind}),!e.plausible&&e.interfaceKind!==`loopback`&&n(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:e.plausibleReason||void 0,children:[s(G,{className:`h-2.5 w-2.5`}),`Unlikely usable`]})]})]})},{key:`kind`,header:`Kind`,nowrap:!0,render:e=>{let t=Pe[e.kind]??Pe.loopback;return s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:t.label})}},{key:`viewer`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Viewer`,R?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-24`,render:e=>{let t=Z(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:e.kind===`loopback`?`Loopback is not a client route.`:`Use this URL in the API / viewer race.`,children:s(C,{checked:t&&B(e),disabled:!t||N.isPending,onChange:()=>H(e),"aria-label":`Viewer: ${e.baseUrl}`})})}},{key:`notifications`,headerRender:()=>n(`span`,{className:`inline-flex items-center gap-1`,children:[`Notifications`,z?s(`span`,{className:`text-[10px] font-normal normal-case text-foreground-subtle`,children:`auto`}):null]}),align:`center`,nowrap:!0,width:`w-28`,render:e=>{let t=Fe(e);return s(`label`,{className:`inline-flex justify-center ${t?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:t?`Notification links and deep links use this address.`:`Loopback is not a client route.`,children:s(C,{checked:t&&V(e),disabled:!t||j.isPending,onChange:()=>U(e),"aria-label":`Notifications: ${e.baseUrl}`})})}}],[R,z,L,F,I,N.isPending,j.isPending,P]);return n(he,{children:[n(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[s(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:`Pin which host addresses exist, then tick the destinations each URL should serve. Viewer auto is IPv4 + public; every other row (including IPv6) can be ticked on.`}),n(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n(S,{size:`sm`,variant:`secondary`,onClick:O,disabled:i.isLoading,children:[s(le,{className:`h-3 w-3 ${i.isLoading?`animate-spin`:``}`}),`Refresh`]}),s(S,{size:`sm`,variant:`secondary`,onClick:k,children:`Probe race`})]})]}),n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Allowed addresses`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:_.length===0?`Auto — every non-loopback / non-link-local interface participates.`:`${_.length} pinned`})]}),n(`div`,{className:`flex items-center gap-1`,children:[n(S,{size:`sm`,variant:`secondary`,onClick:()=>p.mutate(void 0),disabled:p.isPending||d.isPending,title:`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`,children:[s(de,{className:`h-3 w-3`}),p.isPending?`Detecting…`:`Best match`]}),n(S,{size:`sm`,variant:`secondary`,onClick:oe,disabled:_.length===0||d.isPending,children:[s(ue,{className:`h-3 w-3`}),`Clear`]}),E&&s(S,{size:`sm`,variant:`secondary`,onClick:ae,disabled:d.isPending,children:`Discard`}),n(S,{size:`sm`,variant:`primary`,onClick:ie,disabled:!E||d.isPending,children:[s(ye,{className:`h-3 w-3`}),d.isPending?`Saving…`:`Save`]})]})]}),s(`div`,{className:`p-4`,children:s(Ne,{mode:`multiple`,interfaces:m,value:_,onChange:y,disabled:d.isPending,emptyMessage:i.isLoading?`Loading interfaces…`:`No interfaces detected.`})})]}),n(g,{children:[n(`div`,{className:`px-4 py-3 border-b border-border flex items-center justify-between gap-3 flex-wrap`,children:[n(`div`,{children:[s(`div`,{className:`text-sm font-semibold`,children:`Connection endpoints`}),s(`div`,{className:`text-xs text-foreground-subtle`,children:`Ranked URLs this hub advertises. Tick Viewer (many) and Notifications (one).`})]}),n(`div`,{className:`flex items-center gap-1`,children:[!R&&s(S,{size:`sm`,variant:`secondary`,disabled:N.isPending,onClick:()=>N.mutate({baseUrls:[]}),children:`Viewer → auto`}),!z&&s(S,{size:`sm`,variant:`secondary`,disabled:j.isPending,onClick:()=>j.mutate({baseUrl:null}),children:`Notifications → auto`})]})]}),z&&I===null&&s(`p`,{className:`px-4 pt-3 text-[11px] text-amber-600 dark:text-amber-400`,children:`No public address is reachable, so notification media ships as bytes only — a backend that can only take links (WhatsApp, gotify) receives none.`}),s(D,{columns:W,rows:P,rowKey:e=>`${e.priority}-${e.baseUrl}`,minWidthPx:640,bordered:!1,mobileMode:`scroll`,emptyMessage:h.isLoading?`Loading…`:`No endpoints available.`,rowClassName:e=>e.plausible?void 0:`opacity-80`})]})]})}t();var Le={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Q=5e3,Re=3e4,ze={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function Be(){let e=p({capName:`mesh-network`},{refetchInterval:Q}),t=m(void 0,{refetchInterval:Q}),n=r(()=>Y(t.data??[]),[t.data]);return s(J,{title:`Mesh Networks`,subtitle:`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).`,pageIcon:P,itemIcon:q,capability:`mesh-network`,installButtonLabel:`Add mesh`,items:r(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:n.get(e.addonId)??e.addonId,isActive:e.isActive})),[e.data,n]),isLoading:e.isLoading,emptyTitle:`No mesh-network providers installed`,emptyDescription:`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`,renderStatusBadges:e=>s(Ve,{addonId:e.addonId}),renderPrimaryAction:e=>s(He,{addonId:e.addonId}),renderExpandedPanel:e=>s(Ue,{addonId:e.addonId})})}function $(e){let{data:t,isLoading:n}=d({addonId:e},{refetchInterval:Q,retry:!1}),r=t?N.safeParse(t):null;return{status:r?.success?r.data:ze,isLoading:n}}function Ve({addonId:e}){let{status:t}=$(e);return n(i,{children:[s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.joined?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:`bg-foreground-subtle/15 text-foreground-subtle`}`,children:t.joined?`Joined`:`Not joined`}),t.joined&&n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:[t.peerCount,` peer`,t.peerCount===1?``:`s`]})]})}function He({addonId:t}){let r=a(),[c,u]=o(!1),[d,f]=o(null),p=l(),{status:m}=$(t),h=e(()=>{r.invalidateQueries({queryKey:[[`meshNetwork`]]})},[r]),g=ie(),_=E({onSuccess:h}),v=T({onSuccess:h}),y=e(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 Xe(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?N.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=e(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return s(i,{children:m.joined?n(i,{children:[n(S,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:t}),children:[_.isPending?s(V,{className:`h-3 w-3 animate-spin`}):s(pe,{className:`h-3 w-3`}),`Disconnect`]}),n(S,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?s(V,{className:`h-3 w-3 animate-spin`}):s(be,{className:`h-3 w-3`}),`Log out`]})]}):c?n(S,{size:`sm`,variant:`ghost`,onClick:b,children:[s(fe,{className:`h-3 w-3 mr-1`}),` Cancel`]}):n(i,{children:[n(S,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[s(ve,{className:`h-3 w-3`}),`Connect`]}),n(S,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?s(V,{className:`h-3 w-3 animate-spin`}):s(be,{className:`h-3 w-3`}),`Log out`]})]})})}function Ue({addonId:e}){let{status:t}=$(e),r=_({addonId:e},{refetchInterval:Re,retry:!1});return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`p-4 space-y-4`,children:[t.error&&s(oe,{message:t.error}),s(We,{status:t}),t.endpoints.length>0&&n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:`Endpoints`}),t.endpoints.map(e=>n(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[n(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${Le[e.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[e.scope===`public`?s(H,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,e.label]}),n(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[s(K,{className:`h-3 w-3 shrink-0`}),e.url]})]},e.id))]})]}),s(`div`,{className:`border-t border-border`,children:s(Ke,{peers:r.data?.peers??[],loading:r.isLoading})})]})}function We({status:e}){return s(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:`Tenant`,value:e.tenantName||`—`},{label:`User`,value:e.userLogin??`—`},{label:`Control plane`,value:e.controlPlaneUrl||`—`},{label:`Mesh IP`,value:e.meshIp||`—`,mono:!0},{label:`MagicDNS`,value:e.magicDnsHostname||`—`,mono:!0},{label:`DNS suffix`,value:e.magicDnsSuffix||`—`,mono:!0},{label:`Peers`,value:String(e.peerCount)},{label:`Key expiry`,value:e.keyExpiry?Ge(e.keyExpiry):`—`}].map(e=>n(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[s(`span`,{className:`text-foreground-subtle shrink-0`,children:e.label}),s(`span`,{className:`text-foreground truncate ${e.mono?`font-mono`:``}`,children:e.value})]},e.label))})}function Ge(e){let t=e-Date.now();if(t<0)return`Expired ${Ye(e)}`;let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return`in ${n} days`;let r=Math.floor(t/36e5);return r>1?`in ${r}h`:`in ${Math.max(1,Math.floor(t/6e4))} min`}function Ke({peers:t,loading:i}){let a=r(()=>t.map(e=>({...e,_id:e.id})),[t]),o=e(e=>{e&&navigator.clipboard?.writeText(e)},[]),c=r(()=>[{key:`hostname`,header:`Hostname`,render:e=>n(`div`,{className:`flex flex-col`,children:[n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`font-medium text-foreground`,children:e.hostname||`(unknown)`}),e.isSelf&&s(y,{variant:`info`,children:`self`}),e.exitNodeOption&&s(y,{variant:`warning`,children:`exit-node`})]}),e.userLogin&&s(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.userLogin})]})},{key:`magicDns`,header:`MagicDNS`,render:e=>e.magicDns?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs truncate`,children:e.magicDns}),s(`button`,{onClick:()=>o(e.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy MagicDNS`,children:s(F,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:e=>{let t=e.addresses[0]??``;return t?n(`div`,{className:`flex items-center gap-1`,children:[s(`span`,{className:`font-mono text-xs`,children:t}),s(`button`,{onClick:()=>o(t),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":`Copy IP`,children:s(F,{className:`h-3 w-3 text-foreground-subtle`})})]}):s(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:`Connection`,render:e=>n(`div`,{className:`flex items-center gap-1.5`,children:[s(y,{variant:qe(e.connection),children:e.connection}),e.relay&&s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.relay})]})},{key:`routes`,header:`Routes`,render:e=>e.advertisedRoutes.length>0?s(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):s(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:`TX / RX`,render:e=>n(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,Je(e.txBytes),` · ↓ `,Je(e.rxBytes)]})},{key:`lastSeen`,header:`Last seen`,render:e=>s(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?Ye(e.lastSeenMs):`—`})}],[o]);return i&&t.length===0?n(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[s(V,{className:`h-3 w-3 animate-spin inline mr-1`}),` Loading peers…`]}):t.length===0?s(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`No peers visible — your tailnet may be empty or the host is not joined.`}):s(`div`,{className:`p-4`,children:s(D,{columns:c,rows:a,rowKey:e=>e._id,minWidthPx:820})})}function qe(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function Je(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 Ye(e){let t=Date.now()-e;return t<6e4?`just now`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:`${Math.round(t/864e5)}d ago`}function Xe(e){return new Promise(t=>setTimeout(t,e))}t();function Ze(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Qe(){let e=a(),t=u(void 0,{refetchInterval:15e3}),r=w({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),i=h({onSuccess:()=>void e.invalidateQueries({queryKey:[[`localNetwork`]]})}),c=j({onSuccess:()=>{f(!1),m(``),v(``),b(``),e.invalidateQueries({queryKey:[[`localNetwork`]]})}}),l=t.data,[d,f]=o(!1),[p,m]=o(``),[_,v]=o(``),[y,b]=o(``),x=()=>{if(!l?.caCertPem)return;let e=new Blob([l.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`camstack-ca.crt`,n.click(),URL.revokeObjectURL(t)},ee=l?.mode===`uploaded`?`Uploaded`:l?.mode===`generated`?`Generated local CA`:`TLS disabled`;return n(`div`,{className:`flex flex-col gap-4`,children:[s(_e,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:`LAN HTTP`,description:`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`}),n(g,{className:`p-4 space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(R,{className:`h-4 w-4 text-foreground-subtle`}),s(`h3`,{className:`text-sm font-semibold`,children:`Certificate`})]}),t.isError&&s(`p`,{className:`text-xs text-danger`,children:`Could not read TLS status.`}),l?.reissueError&&s(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:l.reissueError}),l?.restartRequired&&s(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:`Restart the hub to apply the new certificate.`}),n(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Mode`}),s(`dd`,{className:`font-medium`,children:ee})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Valid to`}),s(`dd`,{className:`font-mono`,children:l?.validTo?new Date(l.validTo).toLocaleString():`—`})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`Leaf SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.leafFingerprintSha256??void 0,children:Ze(l?.leafFingerprintSha256??null)})]}),n(`div`,{children:[s(`dt`,{className:`text-foreground-subtle`,children:`CA SHA-256`}),s(`dd`,{className:`font-mono`,title:l?.caFingerprintSha256??void 0,children:Ze(l?.caFingerprintSha256??null)})]})]}),l&&l.sans.length>0&&s(`div`,{className:`flex flex-wrap gap-1`,children:l.sans.map(e=>s(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),n(`div`,{className:`flex flex-wrap gap-2`,children:[s(k,{label:`Regenerate`,title:`Issue a new leaf?`,description:`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`,confirmLabel:`Regenerate`,disabled:l?.mode===`uploaded`||r.isPending,action:()=>r.mutateAsync({})}),s(S,{size:`sm`,variant:`outline`,onClick:()=>f(e=>!e),children:`Upload`}),l?.caCertPem&&s(S,{size:`sm`,variant:`outline`,onClick:x,children:`Download CA`}),l?.mode===`uploaded`&&s(k,{label:`Revert to generated`,title:`Drop the uploaded certificate?`,description:`Deletes the uploaded pair and returns to the generated local CA.`,confirmLabel:`Revert`,confirmVariant:`danger`,disabled:i.isPending,action:()=>i.mutateAsync({})})]}),d&&n(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Certificate PEM`,s(`textarea`,{value:p,onChange:e=>m(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`Private key PEM`,s(`textarea`,{value:_,onChange:e=>v(e.target.value),rows:6,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),n(`label`,{className:`block text-[11px] text-foreground-subtle`,children:[`CA PEM (optional)`,s(`textarea`,{value:y,onChange:e=>b(e.target.value),rows:4,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`})]}),s(S,{size:`sm`,disabled:!p.trim()||!_.trim()||c.isPending,onClick:()=>c.mutate({certPem:p,keyPem:_,...y.trim()?{caPem:y}:{}}),children:`Save certificate`}),c.isError&&s(`p`,{className:`text-xs text-danger`,children:c.error instanceof Error?c.error.message:`Upload failed`})]})]})]})}function $e(){return s(`div`,{className:`flex flex-col p-4`,children:s(ge,{defaultTab:`addresses`,tabs:[{id:`local-access`,label:`Local access`,icon:B,content:s(Qe,{})},{id:`addresses`,label:`Network Addresses`,icon:L,content:s(Ie,{})},{id:`remote-access`,label:`Remote Access`,icon:H,content:s(Se,{})},{id:`mesh`,label:`Mesh Networks`,icon:P,content:s(Be,{})},{id:`turn`,label:`TURN Servers`,icon:q,content:s(Oe,{})}]})})}export{$e as NetworkPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e,I as t,K as n,Q as r,S as i,W as a,b as o,i as s,k as c,o as l,p as u,q as d,t as f,x as p,z as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as h}from"./player-overlays-wniETo4u.js";import{En as g,Kn as _,_n as v,mr as y,vn as ee}from"./src-IW6snE8b.js";import{zt as b}from"./src-CsxD-27Y.js";import{t as x}from"./FormBuilder-DfwoGzWg.js";import{n as te,r as S,t as ne}from"./SchemaTabBar-DC28nb9j.js";import{t as re}from"./StableTabPanel-Dc954AQl.js";r();var C=c(function({addonId:r,schema:i,serverValues:o,onImmediateSave:s,onStateChange:c,onAction:l,disabled:u},d){let f=S({schema:i,serverValues:o,onImmediateSave:t(e=>s(r,e),[r,s]),onDeferredSave:t(()=>{},[])});e(d,()=>({flush:()=>{let e={};for(let t of f.pendingKeys)e[t]=f.values[t];return f.handleDiscard(f.pendingKeys),e},discard:()=>f.resetAll()}),[f]);let h=f.pendingKeys,g=h.join(`|`),_=a(()=>h.map(e=>`${e}=${JSON.stringify(f.values[e])}`).join(`,`),[h,f.values]),v=n(c);m(()=>{v.current=c},[c]),m(()=>{let e={};for(let t of h)e[t]=f.values[t];v.current({addonId:r,pendingKeys:h,pendingValues:e})},[r,g,_]);let y=a(()=>{if(l)return(e,t,n)=>l(r,e,t,n)},[r,l]);return p(x,{schema:i,values:f.values,onChange:f.handleChange,disabled:u,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ie(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}r();function D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function ae(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:e,addonIds:r,level:c,deviceId:m,capability:x,sectionIds:S,sectionTab:C,fieldScope:w,emptyMessage:T,extraTabs:E,schemaTabExtras:D,title:O,description:k,selfTabbed:se}){let A=l(),j=h().trpcClient,M=ee(),N=v(),ce=y(),le=_(),P=se===!0||!!(E&&E.length>0),[F,ue]=d(null);if(c===`device`&&!m)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let I=e??`hub`,L=s({queries:r.map(e=>({queryKey:[[`addonSettings`,c===`global`?`getGlobalSettings`:`getDeviceSettings`],{addonId:e,nodeId:I,deviceId:m??null,cap:x??null,scope:w??null}],queryFn:async()=>{let t=e=>e!==null&&w!==void 0?ie(e,w):e;return c===`global`?{addonId:e,result:t(await j.addonSettings.getGlobalSettings.query({addonId:e,nodeId:I,...x?{cap:x}:{}}))}:{addonId:e,result:t(await j.addonSettings.getDeviceSettings.query({addonId:e,deviceId:m,nodeId:I}))}},placeholderData:u}))}),R=L.some(e=>e.isLoading),z=L.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),B=a(()=>{let e=new Set;for(let t of L){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(t.tab??`general`)}return[...e]},[z+`::`+L.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),V=a(()=>new Map((E??[]).map(e=>[e.id,e])),[E]),H=a(()=>{if(!P)return[];let e=[...new Set([...B,...(E??[]).map(e=>e.id),...(D??[]).map(e=>e.tabId)])],t=e=>{let t=V.get(e);if(t?.order!==void 0)return t.order;let n=b[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[P,B,E,V,D]),de=a(()=>{let e=new Map,t=e=>b[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of B)e.set(n,t(n));for(let n of D??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of E??[])e.set(t.id,t.label);return e},[B,E,D]),U=P?F&&H.includes(F)?F:H[0]??null:null,W=U!==null&&V.has(U),G=P?U&&!W?U:void 0:C,{data:K}=g(void 0),fe=a(()=>{let e=new Map;for(let t of K??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[K]),q=n(new Map),J=a(()=>{let e=S?new Set(S):null,t=[];for(let n of L){if(!n.data)continue;let r=n.data.result??q.current.get(n.data.addonId)??null;if(n.data.result!==null&&q.current.set(n.data.addonId,n.data.result),r===null)continue;let{schema:i,values:a}=ae(r),o=i.sections.filter(t=>e?e.has(t.id):!0);if(o.length===0)continue;let s={...r,sections:r.sections.filter(t=>e?e.has(t.id):!0)},c={...i,sections:o};t.push({addonId:n.data.addonId,schemaWithValues:s,schema:c,serverValues:a})}return t},[z,S]),[Y,pe]=d(new Map),me=t(e=>{pe(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),X=n(new Map),he=t(e=>t=>{t?X.current.set(e,t):X.current.delete(e)},[]),Z=t(async(e,t)=>{c===`global`?await M.mutateAsync({addonId:e,nodeId:I,patch:t}):await N.mutateAsync({addonId:e,deviceId:m,nodeId:I,patch:t}),A.invalidateQueries({queryKey:[[`addonSettings`]]})},[M,N,I,c,m,A]),ge=t(async(e,t,n,r)=>{let i=I;try{switch(t){case`reprobe-hwaccel`:await ce.mutateAsync({nodeId:i}),A.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await le.mutateAsync({nodeId:i}),A.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await j.addons.custom.mutate({addonId:e,action:t,input:r});return A.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[ce,le,I,A,j]),_e=t((e,t)=>{Z(e,t)},[Z]),Q=f({mutationFn:async()=>{let e=[];for(let t of J){let n=Y.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(c===`global`?await M.mutateAsync({addonId:e,nodeId:I,patch:t}):await N.mutateAsync({addonId:e,deviceId:m,nodeId:I,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)X.current.get(t)?.discard();A.invalidateQueries({queryKey:[[`addonSettings`]]})}}),ve=t(()=>{for(let e of X.current.values())e.discard()},[]),ye=a(()=>{let e=0;for(let t of J){let n=Y.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[J,Y]),be=a(()=>{let e=new Map;for(let t of J){let n=Y.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[J,Y]);if(R)return p(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=U&&W?V.get(U):void 0;if(!P&&J.length===0)return p(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:T??i(o,{children:[`No addons in`,` `,r.length>0?`[${r.join(`, `)}]`:`the current selection`,` expose`,` `,c,`-level settings on this node.`]})});let xe=Q.isPending;return i(`div`,{className:`space-y-4`,children:[(O||k)&&i(`div`,{className:`border-b border-border pb-2`,children:[O&&p(`h2`,{className:`text-sm font-semibold text-foreground`,children:O}),k&&p(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:k})]}),P&&p(ne,{tabs:H.map(e=>({id:e,label:de.get(e)??e})),activeId:U,onChange:ue,pendingByTab:be}),Q.isError&&i(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[`Save failed: `,String(Q.error?.message??Q.error)]}),p(re,{tabKey:$?`extra:${U??``}`:`tab:${U??``}`,children:$?$.content:(()=>{let e=G?J.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===G).length,0):0,t=G!==null&&e<=1,n=J.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>G?(e.tab??`general`)===G:!0).map(e=>t?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),r=(D??[]).filter(e=>e.tabId===G),a=r.filter(e=>(e.placement??`before`)===`before`),o=r.filter(e=>e.placement===`after`);return n.length===0&&r.length===0?p(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:T??`Nothing to configure here for this node.`}):i(`div`,{className:`space-y-6`,children:[a.map((e,t)=>p(`div`,{children:e.content},`extra-before-${t}`)),n.length>0&&p(oe,{entries:n,paneStates:Y,displayNames:fe,disabled:xe,setPaneRef:he,onPaneStateChange:me,onImmediateSave:_e,onAction:ge,inline:P||!!C}),o.map((e,t)=>p(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!R&&p(te,{pendingCount:ye,onSave:()=>Q.mutate(),onDiscard:ve,saving:xe})]})}function oe({entries:e,paneStates:t,displayNames:n,disabled:r,setPaneRef:o,onPaneStateChange:s,onImmediateSave:c,onAction:l,inline:u}){let f=a(()=>[...e].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let r=n.get(e.addonId)??e.addonId,i=n.get(t.addonId)??t.addonId;return r.localeCompare(i)}),[e,n]),[h,g]=d(f[0]?.addonId??``);m(()=>{f.length!==0&&(f.find(e=>e.addonId===h)||g(f[0].addonId))},[f,h]);let _=f.find(e=>e.addonId===h)??f[0];if(!_)return null;let v=a(()=>l?(e,t,n,r)=>l(e,t,n,r):void 0,[l]),y=e=>p(C,{ref:o(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:c,onStateChange:s,onAction:v,disabled:r},e.addonId);return f.length===1||u?p(`div`,{className:`flex flex-col gap-4`,children:f.map(y)}):i(`div`,{className:`flex flex-col gap-3`,children:[p(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:f.map(e=>{let r=n.get(e.addonId)??e.addonId,a=e.addonId===_.addonId,o=(t.get(e.addonId)?.pendingKeys.length??0)>0;return i(`button`,{type:`button`,onClick:()=>g(e.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[r,o&&p(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},e.addonId)})}),p(`div`,{className:`space-y-2`,children:f.map(e=>p(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{k as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{K as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Br as l,Ir as u,It as d,Pr as f,Qa as p,jt as m,za as h}from"./src-IW6snE8b.js";import{t as g}from"./layers-DR9qbaZc.js";import{t as _}from"./zap-D-TFU8vN.js";import{I as v,K as y,N as b,S as x,i as S}from"./index-Cp84SBzW.js";var C=y(`circuit-board`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M11 9h4a2 2 0 0 0 2-2V3`,key:`1ve2rv`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`M7 21v-4a2 2 0 0 1 2-2h4`,key:`1fwkro`}],[`circle`,{cx:`15`,cy:`15`,r:`2`,key:`3i40o0`}]]),w=y(`lock-open`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]]),T=y(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),E=y(`scale`,[[`path`,{d:`m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`7g6ntu`}],[`path`,{d:`m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z`,key:`ijws7r`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}],[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2`,key:`3gwbw2`}]]),D=y(`usb`,[[`circle`,{cx:`10`,cy:`7`,r:`1`,key:`dypaad`}],[`circle`,{cx:`4`,cy:`20`,r:`1`,key:`22iqad`}],[`path`,{d:`M4.7 19.3 19 5`,key:`1enqfc`}],[`path`,{d:`m21 3-3 1 2 2Z`,key:`d3ov82`}],[`path`,{d:`M9.26 7.68 5 12l2 5`,key:`1esawj`}],[`path`,{d:`m10 14 5 2 3.5-3.5`,key:`v8oal5`}],[`path`,{d:`m18 12 1-1 1 1-1 1Z`,key:`1bh22v`}]]);t();function O(e){return l({addonId:e,projection:`slim`},{staleTime:3e4})}function k(e){return u({deviceId:e},{enabled:Number.isFinite(e)})}var A=3e4,j=2e3;function M(t){let n=e(0);return n.current===0&&(n.current=Date.now()),f({parentDeviceId:t},{enabled:Number.isFinite(t),staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-n.current>=A?!1:j}})}function N(e,t,n){return e.map(e=>{if(e.key===t)return e;let r=e.steps[n];if(!r||r.settings===void 0)return e;let{settings:i,...a}=r,o={...e.steps};return Object.keys(a).length>0?o[n]=a:delete o[n],{...e,steps:o}})}function P(e,t,n){let r=e.filter(e=>e.key!==t).toSorted((e,t)=>e.key.localeCompare(t.key)),i=[...r.filter(e=>!e.enabled),...r.filter(e=>e.enabled),...e.filter(e=>e.key===t)],a;for(let e of i){let t=e.steps[n]?.settings;!t||Object.keys(t).length===0||(a={...a,...t})}return a}function F(e){let t={};for(let n of e){let e=Object.keys(n.steps).length>0;t[n.key]={enabled:n.enabled,weight:Math.max(1,n.weight),...n.maxSessions!==null&&n.maxSessions>0?{maxSessions:n.maxSessions}:{},...e?{steps:n.steps}:{}}}return t}t();function I(e,t,n){return Math.min(Math.max(e,t),n)}function L(e){let t=e.reduce((e,t)=>e+Math.max(t.weight,0),0);if(t<=0){let t=e.length>0?100/e.length:0;return Object.fromEntries(e.map(e=>[e.id,t]))}return Object.fromEntries(e.map(e=>[e.id,Math.max(e.weight,0)/t*100]))}function R(e,t,n,r,i){let a=i.filter(e=>e!==t&&r.has(e)).reduce((t,n)=>t+Math.max(e[n]??0,0),0),o=Math.max(0,100-a),s=i.filter(e=>e!==t&&!r.has(e)),c=s.length===0?o:I(n,0,o),l={...e,[t]:c};if(s.length>0){let e=Math.max(0,o-c)/s.length;for(let t of s)l[t]=e}return l}function z(e,t,n){let r={},i=0,a=[];for(let o of t){let t=Math.max(e[o]??0,0);if(n.has(o)){let e=Math.round(t);r[o]=e,i+=e}else{let e=Math.floor(t);r[o]=e,a.push({id:o,floor:e,frac:t-e})}}let o=Math.max(0,100-i)-a.reduce((e,t)=>e+t.floor,0),s=[...a].sort((e,t)=>t.frac-e.frac);for(let e=0;o>0&&s.length>0;e+=1)r[s[e%s.length].id]+=1,--o;let c=[...a].sort((e,t)=>e.frac-t.frac);for(let e=0;o<0&&c.length>0;e+=1){let t=c[e%c.length].id;r[t]>0&&(--r[t],o+=1)}return r}function B({nodes:e,pending:t,onCommitWeights:r,weightLabel:a=`Detection weight`,emptyHint:l,footnote:u}){let[d,f]=o(()=>L(e)),[p,m]=o(new Set);c(()=>{f(L(e)),m(t=>new Set([...t].filter(t=>e.some(e=>e.id===t))))},[e.map(e=>`${e.id}:${e.weight}`).join(`|`)]);let h=e.map(e=>e.id),g=e=>{m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},_=(e,t)=>{f(n=>R(n,e,t,p,h))},v=()=>{let t=z(d,h,p),n=e.filter(e=>(t[e.id]??0)!==e.weight).map(e=>e.id);if(n.length===0)return;let i=new Set([...n,...p]);r(e.filter(e=>i.has(e.id)).map(e=>({nodeId:e.id,weight:t[e.id]??0})))};if(e.length===0)return s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:l??`No detect-enabled nodes. Enable “Detect” on a node above to distribute detection weight.`});let y=e.length===1;return n(`div`,{className:`space-y-3`,children:[e.map(e=>{let r=d[e.id]??0,i=p.has(e.id);return n(`div`,{className:`flex items-center gap-3`,children:[s(`span`,{className:`w-28 shrink-0 truncate text-xs font-medium text-foreground`,title:e.name,children:e.name}),s(`input`,{"aria-label":`${a} for ${e.name}`,type:`range`,min:0,max:100,step:1,value:Math.round(r),disabled:t||i||y,onChange:t=>_(e.id,Number(t.target.value)),onPointerUp:()=>v(),onKeyUp:()=>v(),className:`h-1.5 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`span`,{className:`w-10 shrink-0 text-right font-mono text-xs tabular-nums text-foreground`,children:[Math.round(r),`%`]}),s(`button`,{type:`button`,onClick:()=>g(e.id),disabled:t||y,"aria-pressed":i,title:i?`Unlock — allow rebalancing`:`Lock this share when others change`,className:`shrink-0 rounded p-1 hover:bg-surface-hover disabled:opacity-40 ${i?`text-amber-400`:`text-foreground-subtle`}`,children:s(i?x:w,{className:`h-3.5 w-3.5`})})]},e.id)}),s(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:u??s(i,{children:`Dragging one slider splits the rest equally across the unlocked nodes; lock a node to pin its share — locked nodes never move and the total always stays at 100%, so a drag is bounded by the room the unlocked nodes leave. Detection only distributes across nodes that can source a camera’s frames.`})})]})}t();function V(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();return e.key===`cpu`||n===`cpu`?{label:`CPU`,Icon:b,hue:`slate`}:t===`openvino`&&n===`npu`?{label:`Intel NPU (AI Boost)`,Icon:_,hue:`sky`}:t===`openvino`&&(n===`gpu`||n===`igpu`)?{label:`Intel iGPU`,Icon:C,hue:`violet`}:t===`edgetpu`?{label:`Coral Edge TPU`,Icon:D,hue:`emerald`}:{label:`${e.backend} ${e.device}`.replace(/\b\w/g,e=>e.toUpperCase()).trim(),Icon:b,hue:`slate`}}var H={sky:`bg-sky-500/12 text-sky-400 ring-sky-500/25`,violet:`bg-violet-500/12 text-violet-400 ring-violet-500/25`,emerald:`bg-emerald-500/12 text-emerald-400 ring-emerald-500/25`,slate:`bg-surface-hover text-foreground-subtle ring-border`};function U({nodeId:e,nodeName:t,isOnline:l}){let u=a(),{data:f,isLoading:_}=h({nodeId:e},{refetchInterval:15e3}),y=p({onSettled:()=>{u.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`]]})}}),b=f?.devices??[],x=f?.reachable??l,[C,w]=o({});c(()=>{w(Object.fromEntries(b.map(e=>[e.key,{enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}])))},[b.map(e=>`${e.key}:${e.enabled}:${e.weight}:${e.maxSessions}:${JSON.stringify(e.steps??{})}`).join(`|`)]);let T=r(()=>b.filter(e=>C[e.key]?.enabled??e.enabled).length,[b,C]),[D,O]=o(null),k=D??T>0,A=t=>{let n=b.map(e=>{let n=t[e.key]??j(e);return{key:e.key,enabled:n.enabled,weight:n.weight,maxSessions:n.maxSessions,steps:n.steps}});y.mutate({agentNodeId:e,inferenceDevices:F(n)})},j=e=>({enabled:e.enabled,weight:e.weight,maxSessions:e.maxSessions,steps:e.steps??{}}),M=e=>{if(!e.available)return;let t=C[e.key]??j(e),n={...C,[e.key]:{...t,enabled:!t.enabled}};w(n),A(n)},N=(e,t)=>{let n=C[e.key]??j(e),r={...C,[e.key]:{...n,maxSessions:t}};w(r),A(r)},P=r(()=>b.filter(e=>(C[e.key]?.enabled??e.enabled)&&e.available),[b,C]),I=r(()=>P.map(e=>({id:e.key,name:V(e).label,weight:C[e.key]?.weight??e.weight})),[P,C]);return n(`div`,{className:`rounded-lg border border-border bg-surface/60`,children:[n(`button`,{type:`button`,onClick:()=>O(!k),className:`flex w-full items-center gap-2.5 px-3.5 py-2.5 text-left`,"aria-expanded":k,children:[s(v,{className:`h-4 w-4 shrink-0 text-foreground-subtle transition-transform ${k?`rotate-90`:``}`}),s(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t}),s(`span`,{className:`ml-auto flex items-center gap-2 text-[11px]`,children:x?T>=2?n(`span`,{className:`inline-flex items-center gap-1 text-emerald-400`,children:[s(g,{className:`h-3.5 w-3.5`}),T,` accelerators`]}):T===1?s(`span`,{className:`text-foreground-subtle`,children:`single default`}):s(`span`,{className:`text-foreground-subtle/70`,children:`auto default`}):n(`span`,{className:`inline-flex items-center gap-1 text-foreground-subtle`,children:[s(S,{className:`h-3.5 w-3.5`}),` unreachable`]})})]}),k&&n(`div`,{className:`space-y-3 border-t border-border px-3.5 py-3`,children:[x?_&&b.length===0?s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`Probing accelerators…`}):b.length===0?s(`p`,{className:`rounded-lg border border-dashed border-border bg-background px-4 py-6 text-center text-xs text-foreground-subtle`,children:`No inference devices reported by this node's platform probe.`}):s(`ul`,{className:`space-y-2`,children:b.map(e=>{let t=V(e),r=C[e.key]??j(e),a=r.enabled&&e.available;return n(`li`,{className:`flex items-center gap-3 rounded-lg border px-3 py-2.5 transition-colors ${e.available?a?`border-primary/40 bg-primary/[0.04] ring-1 ring-inset ring-primary/20`:`border-border bg-surface`:`border-border/60 bg-background opacity-55`}`,children:[s(`span`,{className:`grid h-9 w-9 shrink-0 place-items-center rounded-md ring-1 ring-inset ${H[t.hue]}`,children:s(t.Icon,{className:`h-4.5 w-4.5`})}),n(`div`,{className:`min-w-0 flex-1`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:t.label}),s(d,{variant:`default`,style:`outline`,className:`font-mono text-[9px]`,children:e.format}),!e.available&&s(d,{variant:`warning`,className:`text-[9px]`,children:`unavailable`})]}),n(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[s(`span`,{className:`font-mono`,children:e.key}),!a&&n(i,{children:[s(`span`,{"aria-hidden":!0,children:`·`}),n(`span`,{children:[`default model`,` `,s(`span`,{className:`font-mono text-foreground/80`,children:e.defaultModelId})]})]})]})]}),a&&n(`label`,{className:`flex shrink-0 items-center gap-1 text-[10px] text-foreground-subtle`,children:[s(`span`,{className:`hidden @sm/clustertab:inline`,children:`cap`}),s(`input`,{type:`number`,min:1,placeholder:`∞`,value:r.maxSessions??``,onChange:t=>{let n=t.target.value.trim(),r=n===``?null:Number.parseInt(n,10);N(e,r!=null&&r>0?r:null)},disabled:y.isPending,"aria-label":`Max concurrent sessions for ${t.label}`,className:`w-14 rounded border border-border bg-background px-1.5 py-1 text-right font-mono text-[11px] text-foreground focus:border-primary focus:outline-none`})]}),s(m,{checked:a,onCheckedChange:()=>M(e),disabled:!e.available||y.isPending,"aria-label":`Enable ${t.label}`,className:e.available?``:`cursor-not-allowed opacity-50`})]},e.key)})}):s(W,{}),x&&P.length>=2&&n(`div`,{className:`space-y-3 rounded-lg border border-border bg-background/60 p-3.5`,children:[n(`h4`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:[s(E,{className:`h-3.5 w-3.5`}),`Balancer weight`]}),s(B,{nodes:I,pending:y.isPending,onCommitWeights:e=>{let t={...C};for(let n of e){let e=t[n.nodeId];e&&(t[n.nodeId]={...e,weight:n.weight})}w(t),A(t)},weightLabel:`Balancer weight`,footnote:s(i,{children:`Drag to shift the share of detection sessions each accelerator handles; lock one to pin its share while the others rebalance. Shares always sum to 100%.`})})]}),y.isError&&n(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] text-danger`,children:[`Failed to save inference devices:`,` `,y.error instanceof Error?y.error.message:`unknown error`]})]})]})}function W(){return n(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-border bg-background px-4 py-8 text-center`,children:[s(S,{className:`h-6 w-6 text-foreground-subtle/60`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:`Node unreachable`}),s(`p`,{className:`max-w-sm text-[11px] text-foreground-subtle`,children:`The platform probe couldn't be reached, so its live accelerator set is unavailable. Settings resume once the node reconnects.`})]})}export{P as a,M as c,F as i,O as l,V as n,N as o,B as r,k as s,U as t,T as u};
|