@camstack/addon-admin-ui 0.1.15 → 0.1.16
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/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CKfGBI-Z.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CeLhKMin.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-CykPKLuU.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-DXPQtD9p.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-xMlwAAY4.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-Clpxla3F.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-GvBGLFI2.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-B_akQFxJ.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-BZBxNMgx.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CCRqQaXq.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-B5D3mvYP.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CRHuTm5p.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-XIS4Ck9-.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-BEKtiDI3.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D4TBsvIB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DlquBRmD.js} +1 -1
- package/dist/assets/auth-records-BEfan3dC.js +1 -0
- package/dist/assets/capability-router-map-B3jHfbHt.js +1 -0
- package/dist/assets/devices-CVfa8e_5.js +1 -0
- package/dist/assets/{hostInit-DpSCsYyA.js → hostInit-Bq0J4U4L.js} +1 -1
- package/dist/assets/index-B3BmQjhl.js +1 -0
- package/dist/assets/index-BYRl5bfb.js +1 -0
- package/dist/assets/index-Bftw8yZ0.js +80 -0
- package/dist/assets/index-BqEwAQt-.js +1098 -0
- package/dist/assets/index-ByDDdVKJ.css +1 -0
- package/dist/assets/index-C5--Sp9A.js +80 -0
- package/dist/assets/index-CJH_U_aT.js +1 -0
- package/dist/assets/index-CLnkxPD7.js +1 -0
- package/dist/assets/index-gZlh9vZc.js +1 -0
- package/dist/assets/index-o6URf7uT.js +1 -0
- package/dist/assets/index-otlbS_ZJ.js +1 -0
- package/dist/assets/{remoteEntry-0zDoMSWf.js → remoteEntry-qFyESaJr.js} +1 -1
- package/dist/assets/{schemas-BOzikgNT.js → schemas-XgIEoUz3.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BnGk9xo_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-cGbq1Btt.js} +2 -2
- package/dist/index.html +7 -8
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/server/addon.js +11 -25
- package/dist/server/addon.js.map +1 -1
- package/dist/sw.js +1 -1
- package/package.json +4 -3
- package/dist/assets/capability-router-map-Bqwnkkax.js +0 -1
- package/dist/assets/devices-CFL4MLSo.js +0 -511
- package/dist/assets/index-BP0PcGIN.js +0 -1
- package/dist/assets/index-BQVATbZy.js +0 -5
- package/dist/assets/index-BZhZ3Jvf.js +0 -1
- package/dist/assets/index-BfdtdylV.js +0 -533
- package/dist/assets/index-BkJ1uzOh.js +0 -8420
- package/dist/assets/index-BuajxCgS.js +0 -1
- package/dist/assets/index-CKMQgnc3.js +0 -1
- package/dist/assets/index-DAq7g5_U.js +0 -1
- package/dist/assets/index-DRebE_bu.js +0 -22
- package/dist/assets/index-DUjRaULz.js +0 -1
- package/dist/assets/index-OcuNiGT5.js +0 -34
- package/dist/assets/index-R6tzT59K.css +0 -1
- package/dist/assets/index-pmj5N6Ix.js +0 -5
- package/dist/server/addon.d.ts +0 -12
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import{e as k,c as G,f as U,i as z,h as D,j as ke,R as Ls,k as Ue,l as _s,b as Te,m as br,d as we,g as er,a as an}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-B_akQFxJ.js";import{d as c,c as t,e as ge,a as ln}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{u as Os,f as kt,t as Bs,c as $s,a as $e,g as Qs,b as Gs,d as js,e as Fs}from"./index-DRebE_bu.js";import{d as pt}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BnGk9xo_.js";import{b as ht,a as cn}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CCRqQaXq.js";import{b as zs,a as dn}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CRHuTm5p.js";import{n as tr,m as un,h as Ws,o as Us,p as Hs,_ as pn}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CKfGBI-Z.js";import{c as mn,s as gn,n as qs,B as Vs,F as Ks,_ as fn}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{a as Zs,_ as hn}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-xMlwAAY4.js";import{E as F,A as Ys}from"./capability-router-map-Bqwnkkax.js";import{S as Ft,c as Js}from"./index-BP0PcGIN.js";import{C as Xs,H as bn,R as eo,S as to,a as ro,b as vn,c as bt,d as no,e as so,o as oo,g as Le,x as xn,Y as ao,t as rr,X as Ce,k as Je,l as Oe,f as Qe,am as Xe,ad as Ee,ay as io,B as vt,az as lo,m as Ye,aj as nr,aE as co,an as sr,aq as yn,ar as wn,a8 as Ie,n as uo,M as vr,h as xr,G as po,V as Nn,ao as mo,ap as go,i as fo,A as Cn,aA as ho,aB as bo,p as Sn,aC as vo,aD as xo,ak as yo,al as wo,a0 as xt,O as _e,a6 as No,a7 as Co,a4 as So,a5 as ko,I as or,T as Mo,j as Po,Z as Ao,_ as Do,$ as Eo,K as kn,ab as ar,ac as To,s as Mn,r as Pn,E as Io,aa as Ro,N as zt,a1 as Lo,a2 as _o,a3 as Oo,ai as An,ah as Wt,as as yr,at as Ut,Q as Dn,au as wr,av as Nr,aw as Bo,ag as En,a9 as $o,ae as Qo,af as Tn,q as Go,D as In,u as Rn,v as jo,w as Ln,L as _n,W as ir,y as Fo,z as zo,F as Wo,J as On,P as Uo,U as Ho,ax as qo}from"./devices-CFL4MLSo.js";import"./preload-helper-BlTxHScW.js";import"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-BZBxNMgx.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-B5D3mvYP.js";import"./schemas-BOzikgNT.js";var Bn={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},Vo={primary:"#f59e42",primaryForeground:"#0c0a09",background:"#0c0a09",backgroundElevated:"#1c1917",surface:"#1c1917",surfaceHover:"#292524",border:"#292524",borderSubtle:"#1c1917",foreground:"#fafaf9",foregroundMuted:"#a8a29e",foregroundSubtle:"#78716c",foregroundDisabled:"#57534e",success:"#4ade80",warning:"#fbbf24",danger:"#f87171",info:"#60a5fa",provider:Bn},Ko={primary:"#e67e22",primaryForeground:"#ffffff",background:"#fafaf9",backgroundElevated:"#ffffff",surface:"#f5f5f4",surfaceHover:"#e7e5e4",border:"#d6d3d1",borderSubtle:"#e7e5e4",foreground:"#1c1917",foregroundMuted:"#57534e",foregroundSubtle:"#78716c",foregroundDisabled:"#a8a29e",success:"#16a34a",warning:"#d97706",danger:"#dc2626",info:"#2563eb",provider:Bn},Cr={colors:{dark:Vo,light:Ko},spacing:{xs:2,sm:4,md:8,lg:12,xl:16,"2xl":24,"3xl":32},radius:{sm:4,md:6,lg:8,xl:12},typography:{fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',sizes:{xs:{fontSize:10,lineHeight:14},sm:{fontSize:11,lineHeight:16},base:{fontSize:12,lineHeight:18},lg:{fontSize:13,lineHeight:18},xl:{fontSize:14,lineHeight:20},"2xl":{fontSize:16,lineHeight:22},"3xl":{fontSize:20,lineHeight:28}},weights:{regular:400,medium:500,semibold:600,bold:700}},table:{rowHeight:28,headerHeight:24,cellPaddingX:8,cellPaddingY:6},sidebar:{width:176,itemHeight:28,iconSize:14}};function $n(e,r){const n={...e};for(const s in r){const o=r[s],a=e[s];o!==void 0&&typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof a=="object"&&a!==null?n[s]=$n(a,o):o!==void 0&&(n[s]=o)}return n}function Nd(e){return e?$n(structuredClone(Cr),e):structuredClone(Cr)}function Qn(e){return e.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}function Zo(e){return`--color-${Qn(e)}`}function Sr(e){const r=[];for(const[n,s]of Object.entries(e))n!=="provider"&&r.push(` ${Zo(n)}: ${s};`);return r.join(`
|
|
2
|
-
`)}function Yo(e){const r=[];for(const[n,s]of Object.entries(e))r.push(` --color-provider-${Qn(n)}: ${s};`);return r.join(`
|
|
3
|
-
`)}function Jo(e){const r=[];for(const[n,s]of Object.entries(e))r.push(` --spacing-${n}: ${s}px;`);return r.join(`
|
|
4
|
-
`)}function Xo(e){const r=[];for(const[n,s]of Object.entries(e))r.push(` --radius-${n}: ${s}px;`);return r.join(`
|
|
5
|
-
`)}function Cd(e){const r=Sr(e.colors.dark),n=Sr(e.colors.light),s=Yo(e.colors.dark.provider),o=Jo(e.spacing),a=Xo(e.radius);return`@theme {
|
|
6
|
-
${s}
|
|
7
|
-
${o}
|
|
8
|
-
${a}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.dark {
|
|
12
|
-
${r}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.light {
|
|
16
|
-
${n}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@media (prefers-color-scheme: dark) {
|
|
20
|
-
:root {
|
|
21
|
-
${r.replace(/^ {2}/gm," ")}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@media (prefers-color-scheme: light) {
|
|
26
|
-
:root {
|
|
27
|
-
${n.replace(/^ {2}/gm," ")}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`}var Gn=Te(null),Mt=["dark","light","system"];function jn(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ea(e,r){if(typeof window>"u")return r;const n=localStorage.getItem(e);return n==="dark"||n==="light"||n==="system"?n:r}function kr(e){return e==="system"?jn():e}function Mr({children:e,defaultMode:r="system",storageKey:n="camstack-theme-mode"}){const[s,o]=k(()=>ea(n,r)),[a,i]=k(()=>kr(s)),l=D(m=>{o(m),i(kr(m)),typeof window<"u"&&localStorage.setItem(n,m)},[n]),u=D(()=>{const g=(Mt.indexOf(s)+1)%Mt.length;l(Mt[g]??"dark")},[s,l]);G(()=>{if(typeof document>"u")return;const m=document.documentElement;m.classList.remove("dark","light"),m.classList.add(a)},[s,a]),G(()=>{if(typeof window>"u"||s!=="system")return;const m=window.matchMedia("(prefers-color-scheme: dark)"),g=()=>{i(jn())};return m.addEventListener("change",g),()=>m.removeEventListener("change",g)},[s]);const p=U(()=>({mode:s,resolvedMode:a,setMode:l,toggleMode:u}),[s,a,l,u]);return t(Gn.Provider,{value:p,children:e})}function ta(){const e=we(Gn);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}function w(...e){return Bs($s(e))}var Sd="rounded-lg border border-border bg-surface overflow-hidden",kd="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",Md="p-2 sm:p-3 lg:p-4",Pd="space-y-3 sm:space-y-4",Ad="gap-2 sm:gap-3",Dd="px-3 sm:px-4 py-1.5 sm:py-2",Ed="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",Td="grid grid-cols-1 lg:grid-cols-2",Id="flex flex-col-reverse md:flex-row",Rd="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",Ld="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",_d="text-[11px] sm:text-xs text-foreground",Od="text-[10px] text-foreground-subtle",Bd="text-[11px] sm:text-xs font-medium text-foreground",$d="text-base sm:text-lg font-semibold leading-tight text-foreground",Qd="inline-flex items-center justify-center gap-1 rounded border border-border bg-surface px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",Gd="inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/15 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-primary hover:bg-primary/25 transition-colors disabled:opacity-40",jd="inline-flex items-center justify-center gap-1 rounded border border-danger/40 bg-danger/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-danger hover:bg-danger/20 transition-colors disabled:opacity-40",Fd="inline-flex items-center justify-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-warning hover:bg-warning/20 transition-colors disabled:opacity-40",zd="w-full rounded border border-border bg-background px-1.5 py-0.5 sm:px-2 sm:py-1 text-[11px] sm:text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none",Wd="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",Ud="border-primary/50 bg-primary/15 text-primary",Hd="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function ra(e,r){for(const n of e.slots)for(const s of n.addons)if(s.id===r)return s;return null}function na(e,r){return e.models.find(n=>n.id===r)??null}function sa(e,r){return e.models.find(n=>!!n.formats[r])??null}function oa(e,r){const n=new Set((r.configSchema??[]).map(o=>o.key)),s={};for(const[o,a]of Object.entries(e))n.has(o)&&(s[o]=a);return s}function qd(e){const{source:r,target:n,catalog:s,addonIds:o}=e,a=[];for(const i of o){const l=r.defaults[i];if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no source entry",patch:null});continue}const u=ra(s,i);if(!u){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const p=na(u,l.modelId),m=p!==null&&!!p.formats[n.engine.format];let g,f;if(m)g=l.modelId,f="exact";else{const b=sa(u,n.engine.format);if(!b){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}g=b.id,f="mapped"}const h={enabled:l.enabled,modelId:g,settings:oa(l.settings,u)};a.push({addonId:i,outcome:f,modelId:g,patch:h})}return a}var Pr={idle:{label:"Idle",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-gray-400",icon:"PowerOff"},active:{label:"Active",textColor:"text-success",badgeClass:"border-success/40 bg-success/10 text-success",dotClass:"bg-red-500 animate-pulse",icon:"Activity"},watching:{label:"Watching",textColor:"text-foreground-subtle",badgeClass:"border-border bg-surface-hover text-foreground-subtle",dotClass:"bg-emerald-500",icon:"Eye"},"load-shed":{label:"Load-Shed",textColor:"text-amber-500",badgeClass:"border-amber-500/40 bg-amber-500/10 text-amber-500",dotClass:"bg-amber-500",icon:"AlertTriangle"},paused:{label:"Paused",textColor:"text-gray-400",badgeClass:"border-gray-500/40 bg-gray-500/10 text-gray-400",dotClass:"bg-gray-400",icon:"PauseCircle"}};function Fn(e){return Pr[e]??Pr.watching}function Be(e,r){if(typeof globalThis>"u")return Te(r);const n=globalThis.__camstackSharedContexts,s=n??new Map;n||(globalThis.__camstackSharedContexts=s);const o=s.get(e);if(o)return o;const a=Te(r);return s.set(e,a),a}function ze(e){const n=(typeof globalThis<"u"?globalThis:void 0)?.[e];return n&&typeof n=="object"?n:{}}var aa={singleton:!0,requiredVersion:!1,eager:!0},Ae=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:aa}),Ar="__mf_module_cache__";function ia(){const e=globalThis,r=e[Ar];if(r&&typeof r=="object"){const s=r;return s.share??={},s.remote??={},s}const n={share:{},remote:{}};return e[Ar]=n,n}function la(){const e=ia();e.share.react??=an,e.share["react-dom"]??=cn,e.share["react-dom/client"]??=dn,e.share["react/jsx-runtime"]??=ln,e.share["@tanstack/react-query"]??=pn,e.share["@trpc/client"]??=fn,e.share["@trpc/react-query"]??=hn,e.share["@camstack/ui-library"]??=ze("__camstackUiLibrary"),e.share["@camstack/sdk"]??=ze("__camstackSdk"),e.share["@camstack/types"]??=ze("__camstackTypes")}function ca(){la(),pt.getInstance()===null&&pt.init({name:"admin_ui_host",remotes:[],shared:{react:Ae(()=>an),"react-dom":Ae(()=>cn),"react-dom/client":Ae(()=>dn),"react/jsx-runtime":Ae(()=>ln),"@tanstack/react-query":Ae(()=>pn),"@trpc/client":Ae(()=>fn),"@trpc/react-query":Ae(()=>hn),"@camstack/ui-library":Ae(()=>ze("__camstackUiLibrary")),"@camstack/sdk":Ae(()=>ze("__camstackSdk")),"@camstack/types":Ae(()=>ze("__camstackTypes"))}})}var Vd={frigate:ro,scrypted:to,reolink:eo,homeAssistant:bn,rtsp:Xs},Kd={online:so,offline:no,degraded:bt,unknown:vn},da=$e("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 px-2.5 text-xs gap-1.5",md:"h-8 px-3 text-sm gap-2",lg:"h-9 px-4 text-sm gap-2"}},defaultVariants:{variant:"primary",size:"sm"}}),dt=ke(({className:e,variant:r,size:n,...s},o)=>t("button",{ref:o,className:w(da({variant:r,size:n}),e),...s}));dt.displayName="Button";var ua=$e("inline-flex items-center justify-center rounded-md font-medium transition-colors cursor-pointer disabled:opacity-50 disabled:pointer-events-none",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-surface text-foreground hover:bg-surface-hover",ghost:"hover:bg-surface-hover text-foreground-muted",danger:"bg-danger text-white hover:bg-danger/90",outline:"border border-border bg-transparent hover:bg-surface-hover"},size:{sm:"h-7 w-7",md:"h-8 w-8",lg:"h-9 w-9"}},defaultVariants:{variant:"primary",size:"sm"}}),mt=ke(({className:e,variant:r,size:n,icon:s,...o},a)=>t("button",{ref:a,className:w(ua({variant:r,size:n}),e),...o,children:t(s,{className:"h-4 w-4"})}));mt.displayName="IconButton";var pa=$e("inline-flex items-center rounded-full text-xs font-medium px-2 py-0.5",{variants:{variant:{default:"bg-surface-hover text-foreground",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning",danger:"bg-danger/15 text-danger",info:"bg-info/15 text-info"},styleVariant:{solid:"",outline:"border bg-transparent"}},defaultVariants:{variant:"default",styleVariant:"solid"}}),Ke=ke(({className:e,variant:r,style:n,...s},o)=>t("span",{ref:o,className:w(pa({variant:r,styleVariant:n}),e),...s}));Ke.displayName="Badge";var ma=$e("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),zn=ke(({className:e,variant:r,...n},s)=>t("div",{ref:s,className:w(ma({variant:r}),e),...n}));zn.displayName="Card";function ga({expanded:e,onExpandedChange:r,header:n,children:s,dimmed:o=!1,hideChevron:a=!1,className:i}){return c("div",{className:w("rounded-lg border border-border bg-surface overflow-hidden",o&&"opacity-[0.45]",i),children:[c("div",{role:"button",tabIndex:0,className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer select-none",onClick:()=>r(!e),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),r(!e))},children:[!a&&t("span",{className:"text-foreground-subtle shrink-0",children:e?t(Qe,{className:"h-4 w-4"}):t(Le,{className:"h-4 w-4"})}),n]}),e&&s&&t("div",{className:"border-t border-border px-3 py-3",children:s})]})}var Wn=ke(({className:e,...r},n)=>t("label",{ref:n,className:w("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...r}));Wn.displayName="Label";var fa=$e("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Un=ke(({className:e,orientation:r,...n},s)=>t("div",{ref:s,role:"separator",className:w(fa({orientation:r}),e),...n}));Un.displayName="Separator";var Ze=ke(({className:e,...r},n)=>t("div",{ref:n,className:w("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...r}));Ze.displayName="Skeleton";var Dr=$e("h-7 w-full px-2.5 text-xs bg-surface border rounded-md text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary transition-colors",{variants:{state:{default:"border-border",error:"border-danger"}},defaultVariants:{state:"default"}}),Ht=ke(({className:e,state:r,leftSlot:n,rightSlot:s,...o},a)=>n||s?c("div",{className:"relative flex items-center w-full",children:[n&&t("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:n}),t("input",{ref:a,className:w(Dr({state:r}),n?"pl-7":"",s?"pr-7":"",e),...o}),s&&t("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:s})]}):t("input",{ref:a,className:w(Dr({state:r}),e),...o}));Ht.displayName="Input";var gt=ke(({className:e,options:r,...n},s)=>c("div",{className:"relative w-full",children:[t("select",{ref:s,className:w("h-7 w-full px-2.5 text-xs bg-surface border border-border rounded-md text-foreground appearance-none pr-7 focus:outline-none focus:ring-1 focus:ring-primary",e),...n,children:r.map(o=>t("option",{value:o.value,children:o.label},o.value))}),t("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:t(Qe,{className:"h-3.5 w-3.5"})})]}));gt.displayName="Select";var qt=ke(({className:e,...r},n)=>t("input",{ref:n,type:"checkbox",className:w("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...r}));qt.displayName="Checkbox";var ha=ke(({className:e,checked:r,onCheckedChange:n,label:s,...o},a)=>c("button",{ref:a,role:"switch","aria-checked":r,type:"button",onClick:()=>n(!r),className:w("inline-flex items-center gap-2",e),...o,children:[t("span",{className:w("w-8 h-4 rounded-full transition-colors",r?"bg-primary":"bg-surface-hover"),children:t("span",{className:w("block w-3.5 h-3.5 rounded-full bg-white transition-transform",r?"translate-x-4":"translate-x-0.5")})}),s&&t("span",{className:"text-xs text-foreground",children:s})]}));ha.displayName="Switch";var Hn=Te(null);function qn(){const e=we(Hn);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function ba({children:e,open:r,onOpenChange:n}){const[s,o]=k(!1),a=r??s,i=Ue(),l=D(u=>{n?.(u),r===void 0&&o(u)},[r,n]);return t(Hn.Provider,{value:{open:a,setOpen:l,contentId:i},children:e})}function Zd({children:e,...r}){const{setOpen:n}=qn();return t("button",{type:"button",onClick:()=>n(!0),...r,children:e})}var va=$e("bg-background-elevated border border-border rounded-lg p-4 backdrop:bg-black/50 backdrop:backdrop-blur-sm max-w-[calc(100vw-2rem)] max-h-[calc(100dvh-2rem)] overflow-y-auto",{variants:{width:{sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg"}},defaultVariants:{width:"md"}}),Vn=ke(({className:e,width:r,children:n,...s},o)=>{const{open:a,setOpen:i,contentId:l}=qn(),u=z(null),p=o??u;G(()=>{const g=p.current;g&&(a&&!g.open&&g.showModal(),!a&&g.open&&g.close())},[a,p]);const m=g=>{g.target===g.currentTarget&&i(!1)};return t("dialog",{ref:p,id:l,className:w(va({width:r}),"w-full",e),onClick:m,onClose:()=>i(!1),...s,children:n})});Vn.displayName="DialogContent";function xa({className:e,...r}){return t("div",{className:w("flex flex-col gap-1 mb-3",e),...r})}function ya({className:e,...r}){return t("div",{className:w("flex justify-end gap-2 mt-4",e),...r})}function wa({className:e,...r}){return t("h2",{className:w("text-sm font-semibold text-foreground",e),...r})}function Na({className:e,...r}){return t("p",{className:w("text-xs text-foreground-muted",e),...r})}var Kn=Te(null);function lr(){const e=we(Kn);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function Ca({children:e}){const[r,n]=k(!1),s=Ue(),o=Ue(),a=z(null);return t(Kn.Provider,{value:{open:r,setOpen:n,triggerId:s,contentId:o,triggerRef:a},children:t("div",{className:"relative inline-block",children:e})})}function Sa({children:e,...r}){const{open:n,setOpen:s,triggerId:o,contentId:a,triggerRef:i}=lr();return t("button",{type:"button",ref:i,id:o,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>s(!n),...r,children:e})}function ka({className:e,children:r,align:n="start",offset:s=4,...o}){const{open:a,setOpen:i,contentId:l,triggerId:u,triggerRef:p}=lr(),m=z(null),[g,f]=k(null);if(_s(()=>{if(!a){f(null);return}const b=()=>{const v=p.current;if(!v)return;const x=v.getBoundingClientRect(),y=n==="end"?x.right:x.left;f({top:x.bottom+s,left:y,minWidth:x.width})};return b(),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}},[a,n,s,p]),G(()=>{if(!a)return;const b=x=>{const y=m.current,C=p.current;y&&!y.contains(x.target)&&!C?.contains(x.target)&&i(!1)},v=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",v)}},[a,i,p]),!a||!g||typeof document>"u")return null;const h={position:"fixed",top:g.top,...n==="end"?{right:window.innerWidth-g.left}:{left:g.left},minWidth:g.minWidth};return ht(t("div",{ref:m,id:l,role:"menu","aria-labelledby":u,style:h,className:w("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...o,children:r}),document.body)}function Ma({className:e,icon:r,variant:n="default",children:s,onClick:o,...a}){const{setOpen:i}=lr(),l=D(u=>{o?.(u),i(!1)},[o,i]);return c("button",{type:"button",role:"menuitem",className:w("h-7 text-xs px-2 w-full text-left flex items-center gap-2",n==="danger"?"text-danger hover:bg-danger/10":"text-foreground hover:bg-surface-hover",e),onClick:l,...a,children:[r&&t(r,{size:14}),s]})}var Zn=Te(null);function Yn(){const e=we(Zn);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function Yd({children:e}){const[r,n]=k(!1),s=z(null),o=Ue(),a=()=>{s.current=setTimeout(()=>n(!0),300)},i=()=>{s.current&&clearTimeout(s.current),n(!1)};return t(Zn.Provider,{value:{open:r,show:a,hide:i,tooltipId:o},children:t("div",{className:"relative inline-block",children:e})})}function Jd({children:e,...r}){const{show:n,hide:s,tooltipId:o,open:a}=Yn();return t("div",{onMouseEnter:n,onMouseLeave:s,onFocus:n,onBlur:s,"aria-describedby":a?o:void 0,...r,children:e})}function Xd({className:e,children:r,...n}){const{open:s,tooltipId:o}=Yn();return t("div",{id:o,role:"tooltip",className:w("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-foreground text-background text-xs px-2 py-1 rounded-md shadow-md whitespace-nowrap pointer-events-none transition-opacity duration-150",s?"opacity-100":"opacity-0",e),...n,children:r})}var Er="(max-width: 767px)",Tr="(min-width: 768px) and (max-width: 1023px)";function Jn(e){return r=>{const n=window.matchMedia(e);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}}function Xn(e){return()=>window.matchMedia(e).matches}function es(){return!1}function et(){return er(Jn(Er),Xn(Er),es)}function eu(){return er(Jn(Tr),Xn(Tr),es)}function ts({open:e,onClose:r,title:n,children:s,className:o}){return G(()=>{if(!e)return;const a=i=>{i.key==="Escape"&&r()};return document.addEventListener("keydown",a),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",a),document.body.style.overflow=""}},[e,r]),c(ge,{children:[t("div",{className:w("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:r,"aria-hidden":"true"}),c("div",{role:"dialog","aria-modal":"true",className:w("fixed inset-x-0 bottom-0 z-50 flex flex-col bg-background-elevated border-t border-border rounded-t-xl shadow-2xl transition-transform duration-200 ease-out","max-h-[80dvh]",e?"translate-y-0":"translate-y-full",o),children:[t("div",{className:"flex justify-center pt-2 pb-1",children:t("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),n&&c("div",{className:"flex items-center justify-between px-4 pb-2",children:[t("span",{className:"text-sm font-medium text-foreground",children:n}),t("button",{onClick:r,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:t(Ce,{className:"h-4 w-4"})})]}),t("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:s})]})]})}var rs=Te(null);function ns(){const e=we(rs);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function Pa({children:e,open:r,onOpenChange:n}){const[s,o]=k(!1),a=r??s,i=Ue(),l=Ue(),u=D(p=>{n?.(p),r===void 0&&o(p)},[r,n]);return t(rs.Provider,{value:{open:a,setOpen:u,triggerId:i,contentId:l},children:t("div",{className:"relative inline-block",children:e})})}function Aa({children:e,...r}){const{open:n,setOpen:s,triggerId:o,contentId:a}=ns();return t("button",{type:"button",id:o,"aria-haspopup":"dialog","aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>s(!n),...r,children:e})}function Da({className:e,children:r,...n}){const{open:s,setOpen:o,contentId:a,triggerId:i}=ns(),l=et(),u=z(null);return G(()=>{if(!s||l)return;const p=g=>{const f=u.current,h=document.getElementById(i);f&&!f.contains(g.target)&&!h?.contains(g.target)&&o(!1)},m=g=>{g.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[s,o,i,l]),s?l?t(ts,{open:s,onClose:()=>o(!1),children:r}):t("div",{ref:u,id:a,role:"dialog","aria-labelledby":i,className:w("absolute left-0 top-full z-50 mt-1 bg-background-elevated border border-border rounded-lg shadow-lg p-3",e),...n,children:r}):null}var ss=Te(null);function os(){const e=we(ss);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function tu({value:e,onValueChange:r,defaultValue:n="",className:s,...o}){const[a,i]=k(n),l=e??a,u=D(p=>{r?.(p),e===void 0&&i(p)},[e,r]);return t(ss.Provider,{value:{value:l,setValue:u},children:t("div",{className:s,...o})})}function ru({className:e,...r}){return t("div",{role:"tablist",className:w("flex flex-row border-b border-border-subtle",e),...r})}function nu({value:e,className:r,...n}){const{value:s,setValue:o}=os(),a=e===s,i=`tabpanel-${e}`;return t("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":i,tabIndex:a?0:-1,className:w("h-7 text-xs px-3 transition-colors",a?"border-b-2 border-primary text-foreground font-medium":"text-foreground-muted hover:text-foreground",r),onClick:()=>o(e),...n})}function su({value:e,className:r,...n}){const{value:s}=os();return e!==s?null:t("div",{role:"tabpanel",id:`tabpanel-${e}`,className:w("pt-3",r),...n})}var as=ke(({className:e,...r},n)=>t("div",{ref:n,className:w("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...r}));as.displayName="ScrollArea";function ou({title:e,onClose:r,children:n,defaultWidth:s=360,defaultHeight:o=280,minWidth:a=280,minHeight:i=160,offsetIndex:l=0,className:u}){const[p,m]=k({x:80+l*30,y:80+l*30}),[g,f]=k({w:s,h:o}),[h,b]=k(!1),v=z(!1),x=z(!1),y=z({x:0,y:0}),C=et(),S=D(P=>{P.preventDefault(),v.current=!0,y.current={x:P.clientX-p.x,y:P.clientY-p.y}},[p]),E=D(P=>{P.preventDefault(),P.stopPropagation(),x.current=!0,y.current={x:P.clientX,y:P.clientY}},[]);return G(()=>{const P=A=>{if(v.current&&m({x:A.clientX-y.current.x,y:A.clientY-y.current.y}),x.current){const R=A.clientX-y.current.x,$=A.clientY-y.current.y;y.current={x:A.clientX,y:A.clientY},f(q=>({w:Math.max(a,q.w+R),h:Math.max(i,q.h+$)}))}},M=()=>{v.current=!1,x.current=!1};return window.addEventListener("mousemove",P),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",M)}},[a,i]),C?c("div",{className:w("fixed inset-x-0 bottom-0 z-50 rounded-t-xl border-t border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",u),style:{maxHeight:"60dvh"},children:[c("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[t("span",{className:"text-[11px] font-medium truncate",children:e}),c("div",{className:"flex items-center gap-1 shrink-0",children:[t("button",{onClick:()=>b(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:h?t(vr,{size:12}):t(xr,{size:12})}),t("button",{onClick:r,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:t(Ce,{size:12})})]})]}),!h&&t("div",{className:"flex-1 min-h-0 overflow-y-auto",children:n})]}):c("div",{className:w("fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",u),style:{left:p.x,top:p.y,width:h?280:g.w,height:h?"auto":g.h},children:[c("div",{onMouseDown:S,className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border cursor-move select-none shrink-0 bg-surface",children:[c("div",{className:"flex items-center gap-2 min-w-0",children:[t(po,{size:12,className:"text-foreground-subtle shrink-0"}),t("span",{className:"text-[11px] font-medium truncate",children:e})]}),c("div",{className:"flex items-center gap-1 shrink-0",children:[t("button",{onClick:()=>b(!h),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:h?"Restore":"Minimize",children:h?t(vr,{size:12}):t(xr,{size:12})}),t("button",{onClick:r,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:t(Ce,{size:12})})]})]}),!h&&c("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[n,t("div",{onMouseDown:E,className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",style:{background:"linear-gradient(135deg, transparent 50%, var(--color-foreground-subtle) 50%)",opacity:.4}})]})]})}function Ea({open:e,onClose:r,children:n,className:s,width:o="w-64"}){const a=z(null);return G(()=>{if(!e)return;const i=l=>{l.key==="Escape"&&r()};return document.addEventListener("keydown",i),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[e,r]),c(ge,{children:[t("div",{className:w("fixed inset-0 z-40 bg-black/50 backdrop-blur-sm transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:r,"aria-hidden":"true"}),t("div",{ref:a,role:"dialog","aria-modal":"true",className:w("fixed inset-y-0 left-0 z-50 flex flex-col bg-surface border-r border-border shadow-2xl transition-transform duration-200 ease-out",o,e?"translate-x-0":"-translate-x-full",s),children:n})]})}function au({items:e,className:r}){return t("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${r??""}`,children:e.map((n,s)=>{const o=s===e.length-1,a=!o&&(n.onClick||n.href);return c(Ls.Fragment,{children:[s>0&&t(Le,{className:"h-3 w-3 flex-shrink-0"}),a?n.onClick?t("button",{type:"button",onClick:n.onClick,className:"hover:text-foreground transition-colors",children:n.label}):t("a",{href:n.href,className:"hover:text-foreground transition-colors",children:n.label}):t("span",{className:o?"text-foreground font-medium":"",children:n.label})]},s)})})}function iu({open:e,onClose:r,title:n,subtitle:s,footer:o,children:a,widthClass:i="w-[360px]"}){return G(()=>{if(!e)return;const l=u=>{u.key==="Escape"&&r()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[e,r]),e?c("aside",{className:w("absolute top-0 right-0 bottom-0 z-20 flex flex-col","bg-surface border-l border-border shadow-xl",i),role:"dialog","aria-modal":"false",children:[c("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[c("div",{className:"min-w-0",children:[t("div",{className:"text-sm font-semibold text-foreground truncate",children:n}),s!==void 0&&t("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:s})]}),t("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:t(Ce,{className:"w-4 h-4"})})]}),t("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),o!==void 0&&t("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:o})]}):null}var Ta={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function is({node:e,depth:r,selectedAddonId:n,onSelect:s,agentDots:o}){const a=e.addonId===n,i=o?.[e.addonId]??[];return c("div",{children:[c("button",{type:"button",onClick:()=>s(e.addonId),className:w("w-full flex items-center justify-between gap-2 text-left px-3 py-1.5 text-xs","border-l-2",a?"bg-accent border-primary text-foreground font-medium":"border-transparent hover:bg-muted/40 text-foreground"),style:{paddingLeft:`${12+r*14}px`},children:[t("span",{className:"truncate",children:e.addonName}),i.length>0&&t("span",{className:"flex items-center gap-1 shrink-0",children:i.map(l=>t("span",{title:`${l.agentNodeId}: ${l.state}`,className:w("w-2 h-2 rounded-full",Ta[l.state])},l.agentNodeId))})]}),e.children.map(l=>t(is,{node:l,depth:r+1,selectedAddonId:n,onSelect:s,agentDots:o},l.addonId))]})}function lu({tree:e,selectedAddonId:r,onSelect:n,agentDots:s,className:o}){return t("div",{className:w("flex flex-col py-2",o),children:e.map(a=>t(is,{node:a,depth:0,selectedAddonId:r,onSelect:n,agentDots:s},a.addonId))})}function cu(e){const r=[],n=[],s=new Map;for(const a of e.slots)for(const i of a.addons){const l={addonId:i.id,addonName:i.name,slot:i.slot,inputClasses:i.inputClasses,outputClasses:i.outputClasses,children:[]};i.slot==="audio-classifier"?r.push(l):(n.push(l),s.set(i.id,l))}const o=[];for(const a of n){if(a.inputClasses.length===0){o.push(a);continue}const i=n.find(l=>l.addonId!==a.addonId&&l.outputClasses.some(u=>a.inputClasses.includes(u)));i&&i.children.push(a)}return[...o,...r]}function Ia(e){return e?e.models.map(r=>({id:r.id,name:r.name})):[]}function Pt({step:e,schema:r,allSchemas:n,depth:s=0,onChange:o,onDelete:a,readOnly:i=!1,toggleMode:l="simple",overrideState:u=null,onOverrideChange:p,inheritedEnabled:m,hideModelAndSettings:g=!1}){const[f,h]=k(!1),b=Ia(r);if(b.length>0&&!b.some(x=>x.id===e.modelId)&&!i){const y=(r?.defaultModelId?b.find(C=>C.id===r.defaultModelId):null)??b[0];y&&y.id!==e.modelId&&queueMicrotask(()=>o({...e,modelId:y.id}))}const v=c(ge,{children:[c("div",{className:"flex-1 min-w-0",children:[t("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),t("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),c("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(x=>t("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:x},x)),e.inputClasses.length>0&&e.outputClasses.length>0&&t("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(x=>t("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:x},x))]})]}),!i&&l==="simple"&&t("button",{onClick:x=>{x.stopPropagation(),o({...e,enabled:!e.enabled})},className:w("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e.enabled?"bg-success":"bg-foreground-subtle/30"),children:t("span",{className:w("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e.enabled?"translate-x-6":"translate-x-1")})}),!i&&l==="threeState"&&p&&c("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:x=>x.stopPropagation(),children:[t(At,{label:"Inherit",active:u===null,variant:"inherit",subtext:m===void 0?void 0:m?"on":"off",onClick:()=>p(null)}),t(At,{label:"On",active:u===!0,variant:"on",onClick:()=>p(!0)}),t(At,{label:"Off",active:u===!1,variant:"off",onClick:()=>p(!1)})]})]});return t(ga,{expanded:f,onExpandedChange:h,dimmed:!e.enabled,header:v,children:g?t("p",{className:"text-[11px] text-foreground-subtle",children:"Model and detection settings are managed per agent — open the Pipeline page for this camera's agent to edit them."}):c("div",{className:"space-y-3",children:[t(Vt,{label:"Model",value:e.modelId,disabled:i,options:b.map(x=>({value:x.id,label:x.name})),onChange:x=>o({...e,modelId:x})}),e.slot==="audio-classifier"&&e.engine&&t(Vt,{label:"Runtime",value:`${e.engine.runtime}/${e.engine.backend}`,disabled:i,options:[{value:"node/cpu",label:"Node.js — ONNX CPU"},{value:"node/coreml",label:"Node.js — Apple SoundAnalysis (macOS)"},{value:"python/cpu",label:"Python — ONNX CPU"}],onChange:x=>{const[y,C]=x.split("/");o({...e,engine:{runtime:y,backend:C,format:C==="coreml"?"coreml":"onnx"}})}}),r?.configSchema?.map(x=>t(cr,{field:x,allFields:r.configSchema??[],step:e,disabled:i,onChange:o},x.key))]})})}function Vt({label:e,value:r,options:n,disabled:s,onChange:o}){return c("div",{children:[t("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),c("select",{value:r,onChange:a=>o(a.target.value),disabled:s,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50",children:[n.length===0&&t("option",{value:r,children:r||"default"}),n.map(a=>t("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function Ra({label:e,description:r,value:n,options:s,disabled:o,onChange:a}){function i(l){if(o)return;const u=n.includes(l)?n.filter(p=>p!==l):[...n,l];a(u)}return c("div",{children:[t("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),r&&t("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:r}),t("div",{className:"flex flex-wrap gap-1.5",children:s.map(l=>{const u=n.includes(l.value);return t("button",{type:"button",disabled:o,onClick:()=>i(l.value),className:w("text-[10px] font-medium px-2 py-1 rounded-md border transition-colors",u?"bg-primary/20 text-primary border-primary/40":"bg-surface text-foreground-subtle border-border hover:border-primary/30",o&&"opacity-50 cursor-not-allowed"),children:l.label},l.value)})})]})}function La(e,r,n){const s=r.settings?.[e];if(s!==void 0)return s;const o=n.find(a=>"key"in a&&a.key===e);return o&&"default"in o?o.default:void 0}function cr({field:e,allFields:r,step:n,disabled:s,onChange:o}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:l,equals:u,notEquals:p,in:m,notIn:g}=a,f=La(l,n,r);if(u!==void 0&&f!==u||p!==void 0&&f===p||m!==void 0&&!m.includes(f)||g!==void 0&&g.includes(f))return null}function i(l){o({...n,settings:{...n.settings,[e.key]:l}})}if(e.type==="select"){const l=n.settings?.[e.key],u=typeof l=="string"?l:e.default??"";return t(Vt,{label:e.label,value:u,disabled:s||e.disabled,options:e.options,onChange:i})}if(e.type==="multiselect"){const l=n.settings?.[e.key],u=Array.isArray(l)?l:Array.isArray(e.default)?e.default:[];return t(Ra,{label:e.label,description:e.description,value:u,options:e.options,disabled:s||e.disabled,onChange:i})}if(e.type==="slider"||e.type==="number"){const l=n.settings?.[e.key],u=typeof e.default=="number"?e.default:e.min??0,p=typeof l=="number"?l:u,m=e.min??0,g=e.max??1,f=e.step??.01,h=e.type==="slider"?e.showValue:!0,b="unit"in e?e.unit:void 0,v=e.type==="slider"?e.displayScale:void 0,x=v?p/v:p;return c("div",{children:[c("div",{className:"flex items-center justify-between mb-1",children:[t("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),h&&c("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof x=="number"?x.toFixed(2).replace(/\.?0+$/,""):x,b?` ${b}`:""]})]}),e.description&&t("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),t("input",{type:"range",min:m,max:g,step:f,value:p,disabled:s||e.disabled,onChange:y=>i(Number(y.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const l=n.settings?.[e.key],u=typeof l=="boolean"?l:e.default===!0;return c("label",{className:"flex items-center gap-2",children:[t("input",{type:"checkbox",checked:u,disabled:s||e.disabled,onChange:p=>i(p.target.checked),className:"h-3.5 w-3.5 accent-primary"}),t("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label})]})}if(e.type==="text"||e.type==="password"||e.type==="textarea"){const l=n.settings?.[e.key],u=typeof l=="string"?l:e.default??"",p=e.type==="password"?"password":"text";return c("div",{children:[t("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?t("textarea",{value:u,disabled:s||e.disabled,placeholder:e.placeholder,onChange:m=>i(m.target.value),rows:3,className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50 resize-y"}):t("input",{type:p,value:u,disabled:s||e.disabled,placeholder:e.placeholder,onChange:m=>i(m.target.value),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground focus:outline-none focus:border-primary/50"})]})}return e.type==="separator"?t("div",{className:"border-t border-border my-2"}):e.type==="info"?t("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function At({label:e,active:r,variant:n,subtext:s,onClick:o}){return c("button",{type:"button",onClick:o,className:w("px-2 py-1 text-[10px] font-medium rounded transition-colors",r?n==="on"?"bg-green-500/20 text-green-400":n==="off"?"bg-red-500/20 text-red-400":"bg-primary/20 text-primary":"text-foreground-subtle hover:bg-surface-hover"),children:[e,s&&r&&c("span",{className:"ml-1 opacity-60",children:["(",s,")"]})]})}function ls(e,r){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:r.enabled,modelId:r.modelId,children:[],settings:{...r.settings}}}function _a(e,r,n){return n?{enabled:n.enabled??r.enabled,modelId:n.modelId??r.modelId,settings:n.settings??r.settings}:r}function Oa({addon:e,agentDefault:r,modelsForFormat:n,onChangeAgentConfig:s}){const o=a=>{s?.({...r,...a})};return c("div",{className:"space-y-4 text-xs",children:[c("label",{className:"flex items-center gap-2",children:[t("input",{type:"checkbox",checked:r.enabled,onChange:a=>o({enabled:a.target.checked})}),c("span",{children:["Enabled on this agent (",e.name,")"]})]}),c("div",{children:[t("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),t("select",{className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs",value:r.modelId,onChange:a=>o({modelId:a.target.value}),children:n.map(a=>t("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&c("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[t("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>t(cr,{field:a,allFields:e.configSchema??[],step:ls(e,r),disabled:!1,onChange:i=>o({settings:{...i.settings}})},a.key))]})]})}function Ba({addon:e,agentDefault:r,agentNodeId:n,currentPatch:s,modelsForFormat:o,onChangePatch:a}){const i=_a("device",r,s),l=h=>{const b=h.enabled!==void 0||h.modelId!==void 0||h.settings!==void 0;a?.(b?h:null)},u=h=>{const{enabled:b,...v}=s??{},x=h==="inherit"?v:{...v,enabled:h==="on"};l(x)},p=h=>{const{modelId:b,...v}=s??{},x=h===void 0?v:{...v,modelId:h};l(x)},m=h=>{const{settings:b,...v}=s??{},x=h===void 0?v:{...v,settings:h};l(x)},g=s?.enabled===void 0?"inherit":s.enabled?"on":"off",f=s?.modelId!==void 0;return c("div",{className:"space-y-4 text-xs",children:[c("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(h=>t("button",{type:"button",onClick:()=>u(h),className:w("px-3 py-1 border border-border rounded text-xs capitalize",g===h?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:h},h)),c("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",t("span",{className:"font-semibold",children:r.enabled?"on":"off"})]})]}),c("div",{children:[c("div",{className:"flex items-center justify-between mb-1",children:[t("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),f?t("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>p(void 0),children:"Clear"}):t("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>p(r.modelId),children:"Override"})]}),t("select",{disabled:!f,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:f?s?.modelId??r.modelId:r.modelId,onChange:h=>p(h.target.value),children:o.map(h=>t("option",{value:h.id,children:h.name},h.id))}),!f&&c("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",n]})]}),(e.configSchema?.length??0)>0&&(()=>{const h=s?.settings!==void 0;return c("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[c("div",{className:"flex items-center justify-between",children:[t("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),h?t("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>m(void 0),children:"Clear"}):t("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>m({...r.settings}),children:"Override"})]}),e.configSchema?.map(b=>t(cr,{field:b,allFields:e.configSchema??[],step:ls(e,i),disabled:!h,onChange:v=>m({...v.settings})},b.key)),!h&&c("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",n]})]})})(),c("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[t("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),c("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function du(e){const{mode:r,addon:n,agentDefault:s,agentNodeId:o,currentPatch:a,onChangeAgentConfig:i,onChangePatch:l,engineFormat:u}=e,p=U(()=>n.models.filter(m=>!!m.formats[u]),[n.models,u]);return r==="agent"?t(Oa,{addon:n,agentDefault:s,modelsForFormat:p,onChangeAgentConfig:i}):t(Ba,{addon:n,agentDefault:s,agentNodeId:o,currentPatch:a,modelsForFormat:p,onChangePatch:l})}function $a(e){const r=[],n=(s,o)=>{for(const a of s)r.push({node:a,depth:o}),n(a.children,o+1)};return n(e,0),r}var Ir={detector:{label:"detector",className:"text-emerald-500"},cropper:{label:"cropper",className:"text-blue-500"},classifier:{label:"classifier",className:"text-violet-500"},refiner:{label:"refiner",className:"text-amber-500"},"audio-classifier":{label:"audio classifier",className:"text-pink-500"}};function Qa({slot:e}){const r=Ir[e]??Ir.classifier;return t("span",{className:w("text-[9px] font-semibold uppercase tracking-widest leading-none",r.className),children:r.label})}var Rr="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function Ga({inputs:e,outputs:r}){return e.length===0&&r.length===0?null:c("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(n=>t("span",{className:w(Rr,"bg-blue-500/10 text-blue-500"),children:n},`in-${n}`)),e.length>0&&r.length>0&&t("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),r.map(n=>t("span",{className:w(Rr,"bg-emerald-500/10 text-emerald-500"),children:n},`out-${n}`))]})}function ja({enabled:e,onChange:r,disabled:n}){return t("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:s=>{s.stopPropagation(),r(!e)},className:w("relative inline-flex h-3.5 w-7 shrink-0 items-center rounded-full transition-colors",e?"bg-emerald-500":"bg-foreground-subtle/30",n?"opacity-50 cursor-not-allowed":"cursor-pointer"),title:e?"Click to disable":"Click to enable",children:t("span",{className:w("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function Fa(e){return e.kind==="enabled"?c("span",{className:"inline-flex items-center gap-1",children:[t("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),t("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?c("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[t("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):c("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[t("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function za({node:e,depth:r,agents:n,getCellState:s,onCellClick:o,selectedCell:a,toggleProps:i}){return c(ge,{children:[c("div",{className:"sticky left-0 z-10 bg-surface px-3 py-2 border-b border-border text-xs flex items-start gap-2",style:{paddingLeft:`${12+r*14}px`},children:[c("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[t(Qa,{slot:e.slot}),c("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"font-semibold truncate",children:e.addonName}),t(Ga,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&t("span",{className:"pl-2 pt-0.5 shrink-0",children:t(ja,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),n.map(l=>{const u=s(e.addonId,l.agentNodeId),p=a?.addonId===e.addonId&&a.agentNodeId===l.agentNodeId;return t("button",{type:"button",onClick:()=>o(e.addonId,l.agentNodeId),className:w("text-left px-3 py-1.5 border-b border-l border-border text-xs hover:bg-muted/40",u.kind==="enabled"&&"bg-emerald-500/5",u.kind==="na"&&"bg-muted/30",p&&"ring-2 ring-primary ring-inset"),children:Fa(u)},l.agentNodeId)})]})}function uu({tree:e,agents:r,getCellState:n,onCellClick:s,selectedCell:o,onToggleEnabled:a}){const i=U(()=>$a(e),[e]),l=`minmax(320px, 1fr) repeat(${r.length}, minmax(160px, 220px))`,u=a!==void 0&&r.length===1,p=r[0]?.agentNodeId;return t("div",{className:"overflow-auto border border-border rounded",children:c("div",{className:"grid",style:{gridTemplateColumns:l},children:[t("div",{className:"sticky top-0 left-0 z-20 bg-muted/60 px-3 py-2 text-[10px] uppercase tracking-widest text-foreground-subtle border-b border-border",children:"Step"}),r.map(m=>c("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[t("div",{className:"text-xs font-semibold text-foreground",children:m.agentNodeId}),t("div",{className:"text-[10px] text-foreground-subtle truncate",children:m.engineLabel})]},m.agentNodeId)),i.map(({node:m,depth:g})=>{const f=u&&p!==void 0?n(m.addonId,p):null,h=u&&f!==null?{enabled:f.kind==="enabled",onChange:b=>a?.(m.addonId,b),disabled:f.kind==="na"}:void 0;return t(za,{node:m,depth:g,agents:r,getCellState:n,onCellClick:s,selectedCell:o,toggleProps:h},m.addonId)})]})})}var cs=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,d=cs??Zs();typeof globalThis<"u"&&!cs&&(globalThis.__camstackTrpcReact=d);var dr=Be("camstack:system",null);function Wa({system:e,children:r}){return t(dr.Provider,{value:e,children:r})}function He(){const e=we(dr);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function pu(){return we(dr)}function yt(e,r){const n=He(),s=z(r);s.current=r;const[o,a]=k(n.connectionVersion);G(()=>n.subscribeConnectionEvents((i,l)=>{i==="connected"&&a(l)}),[n]),G(()=>n.subscribeEvent(e,l=>{s.current(l)}),[n,e,o])}function Kt(e){const r=z(e);return r.current=e,r}function ds(e,r){const[n,s]=k(null),o=Kt(r);return yt(e,a=>{const i=a.data,l=o.current;l&&!l(i)||s(i)}),n}function mu(e,r,n){const[s,o]=k(()=>new Map),a=Kt(r),i=Kt(n);yt(e,u=>{const p=u.data,m=i.current;if(m&&!m(p))return;const g=a.current(p);o(f=>{const h=new Map(f);return h.set(g,p),h})});const l=U(()=>Array.from(s.values()),[s]);return{map:s,values:l}}function ur(){const{data:e,isLoading:r}=d.nodes.topology.useQuery(void 0,{staleTime:6e4}),s=ds("cluster.topology-snapshot")?.nodes??e;return{nodes:U(()=>{const a=[];for(const i of s??[])a.push({id:String(i.id??""),name:String(i.name??i.id??""),shortName:i.isHub?"HUB":String(i.name??i.id??""),isHub:!!i.isHub,isOnline:!!i.isOnline,localIps:i.localIps??[],addons:(i.addons??[]).map(l=>({addonId:l.id,capabilities:l.capabilities}))});return a.sort((i,l)=>i.isHub!==l.isHub?i.isHub?-1:1:i.name.localeCompare(l.name)),a},[s]),isLoading:r}}function gu({selectedNodeId:e,onSelect:r,label:n="Node",hideIcon:s=!1,alwaysShow:o=!1}){const{nodes:a}=ur();return!o&&a.length<=1?null:c("div",{className:"flex items-center gap-1.5",children:[!s&&t(fo,{className:"h-3.5 w-3.5 text-foreground-subtle"}),n&&t("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:n}),t("div",{className:"flex rounded-md border border-border overflow-hidden text-[11px] font-medium",children:a.map((i,l)=>{const u=e===i.id;return t("button",{type:"button",onClick:()=>r(i.id),disabled:!i.isOnline,title:i.isOnline?i.name:`${i.name} (offline)`,className:w("px-2.5 py-1 transition-colors",u?"bg-primary/15 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground",l>0&&"border-l border-border",!i.isOnline&&"opacity-50 cursor-not-allowed"),children:i.shortName},i.id)})})]})}var Ua={online:{colorClass:"bg-success",label:"Online"},offline:{colorClass:"bg-danger",label:"Offline"},degraded:{colorClass:"bg-warning",label:"Degraded"},unknown:{colorClass:"bg-foreground-subtle",label:"Unknown"}};function fu({status:e,showDot:r=!0,showLabel:n=!0,size:s="sm",className:o}){const a=Ua[e];return c("span",{className:w("inline-flex items-center gap-1.5",s==="sm"?"text-xs":"text-sm",o),children:[r&&t("span",{className:w("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),n&&t("span",{className:"text-foreground",children:a.label})]})}var Ha={frigate:{colorClass:"bg-provider-frigate",label:"Frigate"},scrypted:{colorClass:"bg-provider-scrypted",label:"Scrypted"},reolink:{colorClass:"bg-provider-reolink",label:"Reolink"},homeAssistant:{colorClass:"bg-provider-homeAssistant",label:"Home Assistant"},rtsp:{colorClass:"bg-provider-rtsp",label:"RTSP"}};function hu({provider:e,showLabel:r=!0,className:n}){const s=Ha[e];return c("span",{className:w("inline-flex items-center gap-1.5 text-xs",n),children:[t("span",{className:w("h-1.5 w-1.5 shrink-0 rounded-sm",s.colorClass),"aria-hidden":"true"}),r&&t("span",{className:"text-foreground",children:s.label})]})}var qa={success:"bg-emerald-400 text-emerald-950",warning:"bg-amber-400 text-amber-950",danger:"bg-red-400 text-red-950",info:"bg-blue-400 text-blue-950",neutral:"bg-foreground-subtle/20 text-foreground"};function Va({children:e,variant:r="neutral",mono:n,className:s}){return t("span",{className:w("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",n&&"font-mono",qa[r],s),children:e})}function bu({version:e,preRelease:r,className:n}){const s=r??/-(alpha|beta|rc|dev|canary|next)/i.test(e);return t(Va,{variant:s?"warning":"success",mono:!0,className:n,children:e})}function vu({label:e,description:r,error:n,required:s,children:o,orientation:a="vertical",className:i}){const l=a==="horizontal";return c("div",{className:w("flex gap-2",l?"flex-row items-center justify-between":"flex-col",i),children:[c("div",{className:w(l?"flex-1":""),children:[c(Wn,{children:[e,s&&t("span",{className:"text-danger ml-0.5",children:"*"})]}),r&&t("p",{className:"text-foreground-subtle text-xs mt-0.5",children:r})]}),t("div",{className:w(l?"shrink-0":""),children:o}),n&&t("p",{className:"text-danger text-xs",children:n})]})}function xu({title:e,subtitle:r,actions:n,className:s}){return c("div",{className:w("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",s),children:[c("div",{children:[t("h1",{className:"text-sm font-semibold text-foreground",children:e}),r&&t("p",{className:"text-foreground-subtle text-xs",children:r})]}),n&&t("div",{className:"flex items-center gap-2 flex-wrap",children:n})]})}function yu({icon:e,title:r,description:n,action:s,className:o}){return c("div",{className:w("flex flex-col items-center justify-center gap-3 py-12",o),children:[e&&t(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),c("div",{className:"flex flex-col items-center gap-1 text-center",children:[t("p",{className:"text-foreground-muted text-sm font-medium",children:r}),n&&t("p",{className:"text-foreground-subtle text-xs max-w-xs",children:n})]}),s&&t("div",{className:"mt-1",children:s})]})}var us=Be("camstack:confirm-dialog",null);function ps(){const e=we(us);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function wu({children:e}){const[r,n]=k(null),s=D(u=>new Promise(p=>{n({...u,resolve:p})}),[]),o=()=>{r?.resolve(!0),n(null)},a=()=>{r?.resolve(!1),n(null)},i={danger:{icon:"text-red-400",button:"bg-red-500 hover:bg-red-600 text-white"},warning:{icon:"text-orange-400",button:"bg-orange-500 hover:bg-orange-600 text-white"},default:{icon:"text-primary",button:"bg-primary hover:bg-primary/90 text-white"}},l=r?i[r.variant??"default"]:i.default;return c(us.Provider,{value:{confirm:s},children:[e,r&&c("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[t("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),c("div",{className:"relative z-10 w-full max-w-sm mx-4 rounded-xl border border-border bg-surface shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",onClick:u=>u.stopPropagation(),children:[c("div",{className:"px-5 pt-5 pb-4",children:[t("h3",{className:"text-sm font-semibold text-foreground",children:r.title}),t("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:r.message})]}),c("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[t("button",{type:"button",onClick:a,className:"px-3 py-1.5 text-xs font-medium rounded-md border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:r.cancelLabel??"Cancel"}),t("button",{type:"button",onClick:o,className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${l.button}`,children:r.confirmLabel??"Confirm"})]})]})]})]})}function Nu({value:e,label:r,trend:n,className:s}){return c(zn,{className:w("flex flex-col gap-1",s),children:[c("div",{className:"flex items-baseline gap-2",children:[t("span",{className:"text-2xl font-semibold text-foreground",children:e}),n&&c("span",{className:w("inline-flex items-center gap-0.5 text-xs font-medium",n.direction==="up"?"text-success":"text-danger"),children:[n.direction==="up"?t(Mo,{className:"h-3 w-3"}):t(Po,{className:"h-3 w-3"}),n.value,"%"]})]}),t("span",{className:"text-xs text-foreground-muted",children:r})]})}function Cu({items:e,className:r}){return t("dl",{className:w("flex flex-col",r),children:e.map(n=>c("div",{className:"flex items-center h-7",children:[t("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:n.key}),t("dd",{className:"text-foreground text-xs",children:n.value})]},n.key))})}function Su({children:e,maxHeight:r=300,className:n}){const[s,o]=k(!1),a=D(()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),2e3)})},[e]);return c("div",{className:w("relative group",n),children:[t(as,{style:{maxHeight:r},children:t("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:t("code",{children:e})})}),t("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:t(mt,{icon:s?Je:Oe,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function ku({filters:e,values:r,onChange:n,className:s}){const o=et(),[a,i]=k(!1),l=(p,m)=>{n({...r,[p]:m})},u=Object.values(r).filter(p=>p!==void 0&&p!=="").length;if(o){const p=e.find(g=>g.type==="search"),m=e.some(g=>g.type!=="search");return c("div",{className:w("flex items-center gap-2",s),children:[p&&t(Ht,{placeholder:p.placeholder??"Search...",value:r[p.key]??"",onChange:g=>l(p.key,g.target.value),leftSlot:t(Ye,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),m&&c(ge,{children:[c("button",{onClick:()=>i(!0),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground-muted hover:bg-surface-hover transition-colors shrink-0",children:[t(uo,{className:"h-3.5 w-3.5"}),"Filters",u>0&&t(Ke,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:u})]}),t(ts,{open:a,onClose:()=>i(!1),title:"Filters",children:t("div",{className:"flex flex-col gap-3",children:e.filter(g=>g.type!=="search").map(g=>{switch(g.type){case"select":return c("div",{children:[t("label",{className:"text-xs text-foreground-muted mb-1 block",children:g.label}),t(gt,{options:g.options,value:r[g.key]??"",onChange:f=>l(g.key,f.target.value),className:"w-full"})]},g.key);case"badge-toggle":return t("div",{className:"flex items-center gap-1 flex-wrap",children:g.options.map(f=>{const b=r[g.key]===f.value;return t("button",{type:"button",onClick:()=>l(g.key,b?void 0:f.value),children:t(Ke,{variant:b?"info":"default",className:"cursor-pointer",children:f.label})},f.value)})},g.key);default:return null}})})})]})]})}return t("div",{className:w("flex items-center gap-2 flex-wrap",s),children:e.map(p=>{switch(p.type){case"search":return t(Ht,{placeholder:p.placeholder??"Search...",value:r[p.key]??"",onChange:m=>l(p.key,m.target.value),leftSlot:t(Ye,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},p.key);case"select":return t(gt,{options:p.options,value:r[p.key]??"",onChange:m=>l(p.key,m.target.value),className:"w-36"},p.key);case"badge-toggle":return t("div",{className:"flex items-center gap-1",children:p.options.map(m=>{const f=r[p.key]===m.value;return t("button",{type:"button",onClick:()=>l(p.key,f?void 0:m.value),children:t(Ke,{variant:f?"info":"default",className:"cursor-pointer",children:m.label})},m.value)})},p.key);default:return null}})})}function Lr({label:e,icon:r,href:n,badge:s,active:o=!1,className:a}){return c("a",{href:n,className:w("flex items-center gap-2 h-7 px-2 text-[11px] transition-colors",o?"border-l-2 border-primary bg-primary/[0.08] text-foreground rounded-r-md":"text-foreground-subtle hover:bg-surface-hover rounded-md",a),children:[t(r,{className:"h-3.5 w-3.5 shrink-0"}),t("span",{className:"truncate flex-1",children:e}),s!==void 0&&t(Ke,{className:"ml-auto text-[10px] px-1.5 py-0",children:s})]})}function _r({logo:e,sections:r,footer:n,onNavigate:s,className:o}){return c("nav",{className:w("bg-surface border-r border-border h-full flex flex-col",o),children:[e&&t("div",{className:"px-3 py-2 shrink-0",children:e}),t("div",{className:"flex-1 overflow-auto px-1 py-1",children:r.map((a,i)=>c("div",{className:w(i>0?"mt-3":""),children:[a.label&&t("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),t("div",{className:"flex flex-col gap-0.5",onClick:s,children:a.items.map(l=>t(Lr,{...l},l.href))})]},i))}),n&&n.length>0&&c("div",{className:"shrink-0 px-1 pb-1",children:[t(Un,{className:"mb-1"}),t("div",{className:"flex flex-col gap-0.5",onClick:s,children:n.map(a=>t(Lr,{...a},a.href))})]})]})}function Mu({sidebar:e,header:r,mobileLogo:n,mobileActions:s,children:o,className:a}){const i=et(),[l,u]=k(!1);return c("div",{className:w("flex h-screen",a),children:[!i&&t(_r,{...e,className:w("w-44",e.className)}),i&&t(Ea,{open:l,onClose:()=>u(!1),width:"w-64",children:t(_r,{...e,onNavigate:()=>u(!1),className:"w-full border-r-0"})}),c("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&c("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[t("button",{onClick:()=>u(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:t(oo,{className:"h-5 w-5"})}),n&&t("div",{className:"flex-1 flex justify-center",children:n}),s&&t("div",{className:"shrink-0",children:s})]}),!i&&r&&c("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[r.breadcrumbs&&r.breadcrumbs.length>0&&t("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:r.breadcrumbs.map((p,m)=>{const g=m===r.breadcrumbs.length-1;return c("span",{className:"flex items-center gap-1",children:[m>0&&t(Le,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),p.href&&!g?t("a",{href:p.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:p.label}):t("span",{className:"text-foreground truncate",children:p.label})]},m)})}),r.actions&&t("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:r.actions})]}),t("main",{className:"flex-1 overflow-auto p-4",children:o})]})]})}function Ka({headerGroups:e,onSortingChange:r,stickyHeader:n,flexRender:s}){return t("thead",{className:w(n&&"sticky top-0 z-10 bg-background"),children:e.map(o=>t("tr",{className:"h-6",children:o.headers.map(a=>t(Za,{header:a,sortable:a.column.getCanSort()&&!!r,flexRender:s},a.id))},o.id))})}function Za({header:e,sortable:r,flexRender:n}){const s=e.column.getIsSorted(),o=s==="asc"?Cn:s==="desc"?Sn:Go;return t("th",{className:w("px-2 py-1 text-left text-[10px] text-foreground-subtle uppercase tracking-wider font-medium",r&&"cursor-pointer select-none"),onClick:r?e.column.getToggleSortingHandler():void 0,children:c("span",{className:"inline-flex items-center gap-1",children:[e.isPlaceholder?null:n(e.column.columnDef.header,e.getContext()),r&&t(o,{className:"h-3 w-3"})]})})}function Ya({row:e,onRowClick:r,rowActions:n,flexRender:s}){const o=n?n(e.original):[];return c("tr",{className:w("h-7 border-b border-border/50",r&&"cursor-pointer","hover:bg-surface-hover"),onClick:r?()=>r(e.original):void 0,children:[e.getVisibleCells().map(a=>t(Ja,{cell:a,flexRender:s},a.id)),o.length>0&&t("td",{className:"px-2 py-1.5 w-8",children:c(Ca,{children:[t(Sa,{className:"p-0.5 rounded hover:bg-surface-hover",onClick:a=>a.stopPropagation(),children:t(Io,{className:"h-3.5 w-3.5 text-foreground-muted"})}),t(ka,{className:"right-0 left-auto",children:o.map(a=>t(Ma,{icon:a.icon,variant:a.variant,onClick:i=>{i.stopPropagation(),a.onClick()},children:a.label},a.label))})]})})]})}function Ja({cell:e,flexRender:r}){return t("td",{className:"px-2 py-1.5 text-xs text-foreground",children:r(e.column.columnDef.cell,e.getContext())})}var Xa=[{value:"10",label:"10"},{value:"25",label:"25"},{value:"50",label:"50"},{value:"100",label:"100"}];function Or({page:e,pageSize:r,total:n,onPaginationChange:s}){const o=Math.max(1,Math.ceil(n/r)),a=e+1;return c("div",{className:"flex items-center justify-between px-2 py-2 text-xs text-foreground-muted",children:[c("div",{className:"flex items-center gap-2",children:[t("span",{children:"Rows per page"}),t("div",{className:"w-16",children:t(gt,{options:Xa,value:String(r),onChange:i=>s?.({pageIndex:0,pageSize:Number(i.target.value)})})})]}),c("div",{className:"flex items-center gap-2",children:[c("span",{children:["Page ",a," of ",o]}),t(mt,{icon:Pn,"aria-label":"Previous page",variant:"ghost",size:"sm",disabled:e<=0,onClick:()=>s?.({pageIndex:e-1,pageSize:r})}),t(mt,{icon:Le,"aria-label":"Next page",variant:"ghost",size:"sm",disabled:a>=o,onClick:()=>s?.({pageIndex:e+1,pageSize:r})})]})]})}function Pu({data:e,columns:r,sorting:n,onSortingChange:s,filtering:o,onFilteringChange:a,pagination:i,onPaginationChange:l,loading:u=!1,emptyState:p,rowActions:m,onRowClick:g,selectable:f=!1,compact:h=!0,stickyHeader:b=!1,className:v,mobileMode:x="scroll"}){const y=U(()=>f?[{id:"__select",header:({table:A})=>t(qt,{checked:A.getIsAllPageRowsSelected(),onChange:A.getToggleAllPageRowsSelectedHandler(),"aria-label":"Select all"}),cell:({row:A})=>t(qt,{checked:A.getIsSelected(),onChange:A.getToggleSelectedHandler(),"aria-label":"Select row"}),enableSorting:!1},...r]:r,[r,f]),C=Os({data:e,columns:y,state:{...n!==void 0&&{sorting:n},...o!==void 0&&{columnFilters:o},...i!==void 0&&{pagination:{pageIndex:i.page,pageSize:i.pageSize}}},onSortingChange:s?M=>{const A=typeof M=="function"?M(n??[]):M;s(A)}:void 0,onColumnFiltersChange:a?M=>{const A=typeof M=="function"?M(o??[]):M;a(A)}:void 0,getCoreRowModel:Fs(),getSortedRowModel:js(),getFilteredRowModel:Gs(),getPaginationRowModel:i?Qs():void 0,manualPagination:i!==void 0,pageCount:i?Math.ceil(i.total/i.pageSize):void 0}),S=!!m;if(et()&&x==="cards"){const M=C.getRowModel().rows;return u?t("div",{className:w("space-y-2",v),children:Array.from({length:3}).map((A,R)=>c("div",{className:"rounded-lg border border-border bg-surface p-3 space-y-2",children:[t(Ze,{className:"h-3 w-3/4"}),t(Ze,{className:"h-3 w-1/2"}),t(Ze,{className:"h-3 w-2/3"})]},R))}):M.length===0?t("div",{className:w("text-center py-8 text-xs text-foreground-muted",v),children:p??"No data"}):c("div",{className:w("space-y-2",v),children:[M.map(A=>c("div",{className:w("rounded-lg border border-border bg-surface p-3 space-y-1.5",g&&"cursor-pointer hover:bg-surface-hover transition-colors"),onClick:g?()=>g(A.original):void 0,children:[A.getVisibleCells().filter(R=>R.column.id!=="__select").map(R=>{const $=R.column.columnDef.header,q=typeof $=="string"?$:R.column.id;return c("div",{className:"flex items-baseline justify-between gap-2 text-xs",children:[t("span",{className:"text-foreground-muted shrink-0",children:q}),t("span",{className:"text-foreground text-right truncate",children:kt(R.column.columnDef.cell,R.getContext())})]},R.id)}),m&&t("div",{className:"flex items-center gap-1 pt-1 border-t border-border mt-1.5",children:m(A.original).map((R,$)=>t("button",{onClick:q=>{q.stopPropagation(),R.onClick()},className:w("text-[11px] px-2 py-1 rounded-md transition-colors",R.variant==="danger"?"text-danger hover:bg-danger/10":"text-foreground-muted hover:bg-surface-hover"),children:R.label},$))})]},A.id)),i&&t(Or,{page:i.page,pageSize:i.pageSize,total:i.total,onPaginationChange:l})]})}return c("div",{className:w("overflow-x-auto",v),children:[c("table",{className:"w-full border-collapse",children:[t(Ka,{headerGroups:C.getHeaderGroups(),onSortingChange:s,stickyHeader:b,flexRender:kt}),t("tbody",{children:u?t(ei,{colSpan:y.length+(S?1:0),compact:h}):C.getRowModel().rows.length===0?t("tr",{children:t("td",{colSpan:y.length+(S?1:0),className:"text-center py-8 text-xs text-foreground-muted",children:p??"No data"})}):C.getRowModel().rows.map(M=>t(Ya,{row:M,onRowClick:g,rowActions:m,flexRender:kt},M.id))})]}),i&&t(Or,{page:i.page,pageSize:i.pageSize,total:i.total,onPaginationChange:l})]})}function ei({colSpan:e,compact:r}){return t(ge,{children:Array.from({length:5}).map((n,s)=>t("tr",{className:r?"h-7":"h-9",children:Array.from({length:e}).map((o,a)=>t("td",{className:"px-2 py-1.5",children:t(Ze,{className:"h-3 w-full"})},a))},s))})}var ti={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function Au({title:e,subtitle:r,status:n,selected:s,onClick:o,badges:a,actions:i,offlineAction:l,className:u}){const p=n==="offline";return c("div",{onClick:o,className:w("w-full rounded-lg border p-3 text-left transition-colors",o&&"cursor-pointer",s?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",p&&!s&&"opacity-50",u),children:[c("div",{className:"flex items-center justify-between mb-2",children:[t("span",{className:"text-sm font-medium truncate",children:e}),n&&t("span",{className:w("h-2 w-2 rounded-full shrink-0",ti[n])})]}),r&&t("div",{className:"text-[11px] text-foreground-muted",children:r}),a&&a.length>0&&t("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((m,g)=>{const f=w("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",s?"bg-primary/20":"bg-surface-hover",m.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return m.onClick?c("button",{onClick:h=>{h.stopPropagation(),m.onClick()},className:f,children:[m.icon,m.label]},g):c("span",{className:f,children:[m.icon,m.label]},g)})}),!p&&i&&i.length>0&&t("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((m,g)=>t("button",{onClick:f=>{f.stopPropagation(),m.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:m.label,"aria-label":m.label,children:m.icon},g))}),p&&l&&t("div",{className:"mt-2",onClick:m=>m.stopPropagation(),children:l})]})}function Du({children:e,minCardWidth:r=220,gap:n=3,className:s}){return t("div",{className:w("p-4 overflow-y-auto flex-1 content-start",s),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${r}px, 1fr))`,gap:`${n*4}px`},children:e})}var ri="capability.binding-changed";function wt(e,r){const[n,s]=k(null);return G(()=>{if(r===null){s(null);return}let o=!1;const a=async()=>{try{const l=await e.deviceManager.getBindings.query({deviceId:r});o||s(l)}catch{o||s(l=>l)}};a();const i=e.live?.onEvent.subscribe({category:ri},{onData:l=>{const u=l.data?.source;if(!u){a();return}u.type==="device"&&u.id===r&&a()}});return()=>{o=!0,i?.unsubscribe()}},[e,r]),U(()=>n?Js(e,n):null,[e,n])}function ms(e){const r=D(s=>e?e.subscribe(()=>s()):()=>{},[e]),n=D(()=>e?.value,[e]);return er(r,n,n)}function ni(e,r,n){const s=wt(e,r),o=s?n(s.state):void 0;return ms(o)}function tt(e){const r=wt(e.trpc,e.deviceId),n=r!==null?e.slice(r):void 0,s=ms(n),o=r!==null?e.cap(r):void 0,u=(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&o!==void 0&&s!==void 0;return{dev:r,cap:o,slice:s,available:u}}function Eu(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}var si={minimal:{showIntegrationIcon:!1,showParentBadge:!1,showSnapshot:!1,showBattery:!1,showStableId:!1,showId:!1,showSwitchToggle:!0,showChildrenAccordion:!1},compact:{showIntegrationIcon:!0,showParentBadge:!0,showSnapshot:!0,showBattery:!0,showStableId:!1,showId:!1,showSwitchToggle:!0,showChildrenAccordion:!0},expanded:{showIntegrationIcon:!1,showParentBadge:!0,showSnapshot:!0,showBattery:!0,showStableId:!0,showId:!0,showSwitchToggle:!0,showChildrenAccordion:!0}};function oi(e){const r=si[e.variant??"compact"];return{showIntegrationIcon:e.showIntegrationIcon??r.showIntegrationIcon,showParentBadge:e.showParentBadge??r.showParentBadge,showSnapshot:e.showSnapshot??r.showSnapshot,showBattery:e.showBattery??r.showBattery,showStableId:e.showStableId??r.showStableId,showId:e.showId??r.showId,showSwitchToggle:e.showSwitchToggle??r.showSwitchToggle,showChildrenAccordion:e.showChildrenAccordion??r.showChildrenAccordion}}var ai={siren:vt,floodlight:_n,spotlight:xn,"pir-sensor":Ln,chime:jo,autotrack:Rn,nightvision:rr,"privacy-mask":Mn,doorbell:In},ii={camera:or,hub:zt,nvr:zt,light:_n,siren:vt,switch:Wo,sensor:Ln,thermostat:zo,button:Fo,generic:ir};function gs(e){return e.role?ai[e.role]??ir:ii[e.type.toLowerCase()]??or}var fs={"native-snapshot":Ho,"two-way-audio":Dn,"pan-tilt-zoom":Rn,"ptz-autotrack":Uo,"doorbell-button":In,"motion-trigger":_e,"battery-operated":kn,rebootable:On},hs={"native-snapshot":"Native snapshot","two-way-audio":"Two-way audio","pan-tilt-zoom":"Pan-Tilt-Zoom","ptz-autotrack":"PTZ autotrack","doorbell-button":"Doorbell button","motion-trigger":"Motion trigger","battery-operated":"Battery operated",rebootable:"Rebootable"},li={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},bs=new Set(["camera","hub","nvr"]);function vs(e){return!bs.has(e.type.toLowerCase())}function Br(e){return e.role?!0:!bs.has(e.type.toLowerCase())}function xs(e){return(e.features??[]).includes("motion-trigger")}function ci(e){if(e.length<=24)return e;const r=e.lastIndexOf(":");if(r>=0&&r<e.length-4)return e.slice(r+1);const n=e.split("-");if(n.length>2){const s=n.slice(-2).join("-");if(s.length>=6)return s}return`…${e.slice(-18)}`}function di({trpc:e,accessoryChildren:r,adoptedChildren:n,onNavigate:s}){return c("div",{className:"border-t border-border-subtle/50",children:[n.length>0&&t($r,{trpc:e,label:"Adopted devices",rows:n,onNavigate:s}),r.length>0&&t($r,{trpc:e,label:"Accessories",rows:r,onNavigate:s})]})}function $r({trpc:e,label:r,rows:n,onNavigate:s}){return c("div",{children:[t("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:r}),t("ul",{children:n.map(o=>t(ui,{trpc:e,child:o,onNavigate:s},o.id))})]})}function ui({trpc:e,child:r,onNavigate:n}){const s=!r.disabled,o=s&&vs(r),a=s&&xs(r),i=gs(r);return t("li",{children:c("div",{onClick:l=>{l.stopPropagation(),n(r.id)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-surface-hover transition-colors cursor-pointer",children:[t(i,{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),t("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:r.name}),a&&t(mi,{trpc:e,deviceId:r.id,features:r.features}),o&&t(pi,{trpc:e,deviceId:r.id}),t("span",{className:w("h-1.5 w-1.5 rounded-full flex-shrink-0",r.online?"bg-success":"bg-foreground-subtle/40"),title:r.online?"Online":"Offline"})]})})}function pi({trpc:e,deviceId:r}){const{dev:n,cap:s,slice:o,available:a}=tt({trpc:e,deviceId:r,cap:g=>g.switch,slice:g=>g.state.switch}),[i,l]=k(!1);if(n!==null&&!s)return null;const u=o?.on===!0,p={transform:u?"translateX(14px)":"translateX(2px)"},m=async g=>{if(g.stopPropagation(),!(i||!a||!s)){l(!0);try{await s.setState({on:!u})}finally{l(!1)}}};return t("button",{type:"button",onClick:g=>{m(g)},disabled:i||!a,className:w("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",u?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?u?"Turn off":"Turn on":"Awaiting state…","aria-pressed":u,children:t("span",{className:w("absolute h-3 w-3 rounded-full transition-all",u?"bg-success":"bg-foreground-subtle"),style:p})})}function mi({trpc:e,deviceId:r,features:n}){const{dev:s,cap:o,slice:a,available:i}=tt({trpc:e,deviceId:r,cap:g=>g.motionTrigger,slice:g=>g.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,u]=k(!1);if(s!==null&&!o)return null;const p=a?.enabled===!0,m=async g=>{if(g.stopPropagation(),!(l||!i||!o)){u(!0);try{await o.setMotionTrigger({enabled:!p})}finally{u(!1)}}};return t("button",{type:"button",onClick:g=>{m(g)},disabled:l||!i,className:w("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",p?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?p?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":p,children:t(_e,{className:"h-2.5 w-2.5"})})}function ys({trpc:e,device:r,flags:n}){if(!!r.disabled)return null;const o=r.type.toLowerCase(),a=n.showSwitchToggle&&vs(r),i=xs(r),l=o==="hub"||o==="nvr",u=(r.features??[]).includes("rebootable"),p=l&&u;return c(ge,{children:[i&&t(fi,{trpc:e,deviceId:r.id,features:r.features}),a&&t(gi,{trpc:e,deviceId:r.id}),p&&t(bi,{trpc:e,deviceId:r.id})]})}function gi({trpc:e,deviceId:r}){const{dev:n,cap:s,slice:o,available:a}=tt({trpc:e,deviceId:r,cap:g=>g.switch,slice:g=>g.state.switch}),[i,l]=k(!1);if(n!==null&&!s)return null;const u=o?.on===!0,p={transform:u?"translateX(14px)":"translateX(2px)"},m=async g=>{if(g.stopPropagation(),!(i||!a||!s)){l(!0);try{await s.setState({on:!u})}finally{l(!1)}}};return t("button",{type:"button",onClick:g=>{m(g)},disabled:i||!a,className:w("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",u?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?u?"Turn off":"Turn on":"Awaiting state…","aria-pressed":u,children:t("span",{className:w("absolute h-3 w-3 rounded-full transition-all",u?"bg-success":"bg-foreground-subtle"),style:p})})}function fi({trpc:e,deviceId:r,features:n}){const{dev:s,cap:o,slice:a,available:i}=tt({trpc:e,deviceId:r,cap:g=>g.motionTrigger,slice:g=>g.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:n}),[l,u]=k(!1);if(s!==null&&!o)return null;const p=a?.enabled===!0,m=async g=>{if(g.stopPropagation(),!(l||!i||!o)){u(!0);try{await o.setMotionTrigger({enabled:!p})}finally{u(!1)}}};return t("button",{type:"button",onClick:g=>{m(g)},disabled:l||!i,className:w("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",p?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(l||!i)&&"opacity-50"),title:i?p?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":p,children:t(_e,{className:"h-2.5 w-2.5"})})}var Dt=168,hi=4;function bi({trpc:e,deviceId:r}){const{dev:n,cap:s}=tt({trpc:e,deviceId:r,cap:x=>x.reboot,slice:()=>{}}),o=z(null),a=z(null),[i,l]=k(null),[u,p]=k(!1),m=n!==null&&s!==void 0&&s!==null,g=i!==null,f=()=>l(null),h=()=>{const x=o.current;if(!x)return;const y=x.getBoundingClientRect(),C=y.right-Dt,S=Math.max(8,Math.min(C,window.innerWidth-Dt-8)),E=y.bottom+hi;l({top:E,left:S})};if(G(()=>{if(!g)return;const x=C=>{const S=o.current,E=a.current,P=C.target;P!==null&&(S&&S.contains(P)||E&&E.contains(P)||f())},y=C=>{C.key==="Escape"&&(C.stopPropagation(),f())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",y)}},[g]),n!==null&&!s)return null;const b=x=>{x.stopPropagation(),g?f():h()},v=async()=>{if(!(u||!m||!s)){p(!0),f();try{await s.reboot({})}finally{p(!1)}}};return c(ge,{children:[t("button",{ref:o,type:"button",onClick:b,disabled:u||!m,className:w("inline-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",(u||!m)&&"opacity-50",g&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":g,children:t(Nn,{className:"h-3 w-3"})}),i&&ht(t("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:Dt},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:x=>x.stopPropagation(),children:c("button",{type:"button",role:"menuitem",onClick:()=>{v()},disabled:u||!m,className:w("flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-[11px] text-foreground","hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed"),children:[t(On,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),t("span",{children:"Reboot device"})]})}),document.body)]})}var vi=Object.freeze([]);function xi(e){return e==="native"?"native":"enhanced"}function yi(e){return e.map(r=>({kind:"marker",feature:r}))}function wi(e,r){const n=new Map,s=r.entries??[];for(const a of s)n.set(a.capName,a);const o=[];for(const a of e){const i=li[a];if(i===void 0){o.push({kind:"marker",feature:a});continue}const l=n.get(i);l&&o.push({kind:xi(l.kind),feature:a,capName:i})}return o}function Ni(e,r,n){const[s,o]=k(null),[a,i]=k(!1),[l,u]=k(!0);return G(()=>{if(r===null){o(null),i(!1),u(!1);return}let p=!1;u(!0),i(!1);const m=async()=>{try{const f=await e.deviceManager.getBindings.query({deviceId:r});if(p)return;o(f),u(!1)}catch{if(p)return;i(!0),u(!1)}};m();const g=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:f=>{const h=f.data?.source;if(!h){m();return}h.type==="device"&&h.id===r&&m()}});return()=>{p=!0,g?.unsubscribe()}},[e,r]),n.length===0?{loading:l,resolved:vi}:l||a||!s?{loading:l,resolved:yi(n)}:{loading:!1,resolved:wi(n,s)}}var Ci=[];function ws({trpc:e,device:r,flags:n,accessoryCount:s,adoptedCount:o,showFeatureRow:a=!1}){const i=s+o,l=n.showChildrenAccordion&&i>0,u=r.features??Ci,p=a&&u.length>0,{resolved:m}=Ni(e,p?r.id:null,u),g=p&&m.length>0;return!l&&!g?null:c("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[l&&t(Si,{accessoryCount:s,adoptedCount:o}),g&&t(ki,{resolved:m})]})}function Si({accessoryCount:e,adoptedCount:r}){const n=e+r;if(n===0)return null;const s=r>0&&e>0?`${String(r)} adopted · ${String(e)} accessor${e===1?"y":"ies"}`:r>0?`${String(r)} adopted`:`${String(e)} accessor${e===1?"y":"ies"}`;return c("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:s,children:["+",n]})}var Ns=240,Qr=200;function ki({resolved:e}){const r=z(null),[n,s]=k(null);return c("span",{ref:r,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:()=>{const i=r.current;if(!i)return;const l=i.getBoundingClientRect(),m=window.innerHeight-l.bottom>=Qr?l.bottom+4:l.top-Qr-4,g=Math.max(8,Math.min(l.left,window.innerWidth-Ns-8));s({top:m,left:g})},onMouseLeave:()=>s(null),children:[e.map(i=>{const l=fs[i.feature];return l?t("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:hs[i.feature]??i.feature,children:t(l,{className:"h-2.5 w-2.5"})},i.feature):null}),n&&ht(t(Mi,{resolved:e,position:n}),document.body)]})}function Mi({resolved:e,position:r}){return c("div",{style:{position:"fixed",top:r.top,left:r.left,width:Ns,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[t("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),t("ul",{className:"space-y-0.5",children:e.map(n=>t(Pi,{entry:n},n.feature))})]})}function Pi({entry:e}){const r=fs[e.feature],n=hs[e.feature]??e.feature;return c("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[c("span",{className:"flex items-center gap-1.5 text-foreground",children:[r&&t(r,{className:"h-3 w-3 text-foreground-subtle"}),t("span",{children:n})]}),t(Ai,{kind:e.kind})]})}function Ai({kind:e}){return e==="marker"?t("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):t("span",{className:w("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Cs({device:e,variant:r,flags:n,parent:s,integrationIcon:o,hasChildren:a,expanded:i,onToggleExpand:l,onNavigateToParent:u}){const p=gs(e);return c("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[n.showChildrenAccordion&&a?t("button",{type:"button",onClick:m=>{m.stopPropagation(),l()},className:"flex h-3.5 w-3.5 items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0","aria-label":i?"Collapse children":"Expand children","aria-expanded":i,children:i?t(Qe,{className:"h-3 w-3"}):t(Le,{className:"h-3 w-3"})}):n.showChildrenAccordion?t("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,t(p,{className:w("text-foreground-subtle flex-shrink-0",r==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),c("div",{className:"flex-1 min-w-0",children:[c("div",{className:"flex items-center gap-1.5 min-w-0",children:[n.showIntegrationIcon&&o&&t("span",{className:"flex-shrink-0",children:o}),t("span",{className:w("font-semibold text-foreground truncate",r==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(n.showId||n.showStableId)&&c("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:n.showStableId?`stableId: ${e.stableId}`:void 0,children:[n.showId&&c("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),n.showId&&n.showStableId&&t("span",{className:"flex-shrink-0 opacity-50",children:"·"}),n.showStableId&&t("span",{className:"truncate",children:ci(e.stableId)})]}),n.showParentBadge&&s&&c("button",{type:"button",onClick:m=>{m.stopPropagation(),u(s.id)},className:"mt-0.5 inline-flex max-w-full items-center gap-1 text-[9px] text-foreground-subtle hover:text-primary transition-colors",title:`Open parent: ${s.name} (#${String(s.id)})`,children:[t(zt,{className:"h-2.5 w-2.5 shrink-0"}),c("span",{className:"truncate",children:["Under: ",s.name]})]})]})]})}function Di(e,r){return ni(e,r,s=>s.battery)??null}function Ei(e,r){const n=wt(e,r),s=z(!1),{data:o,isLoading:a,isFetching:i,refetch:l}=un({queryKey:["device",r,"snapshot"],queryFn:()=>{if(!n)throw new Error("useDeviceSnapshotImage: device proxy not ready");const m=s.current;return s.current=!1,n.snapshot?.getSnapshot({force:m})??null},enabled:n!==null&&r!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),u=o?`data:${o.contentType};base64,${o.base64}`:null;function p(){s.current=!0,l()}return{src:u,loading:a||i,refresh:p}}function Ti(e){return e<=10?Ao:e<=30?Do:e>=95?Eo:kn}function Ii(e,r){return r!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function Ri({status:e,variant:r="compact",className:n}){if(!e)return null;const s=Ti(e.percentage),o=Ii(e.percentage,e.charging),a=e.charging==="solar"?xn:e.charging==="dc"?ao:null,i=e.sleeping;return c("span",{className:w("inline-flex items-center gap-1 text-[10px] font-medium",o,n),title:`Battery: ${Math.round(e.percentage)}%`+(e.charging!=="none"?` · charging (${e.charging})`:"")+(e.sleeping?" · sleeping":""),children:[t(s,{className:"h-3.5 w-3.5"}),c("span",{children:[Math.round(e.percentage),"%"]}),a&&t(a,{className:"h-3 w-3"}),i&&t(rr,{className:"h-3 w-3 text-blue-300"}),r==="full"&&e.charging!=="none"&&t("span",{className:"text-foreground-subtle",children:e.charging})]})}function Ss({trpc:e,device:r,status:n,enabled:s,showStatusPills:o=!1}){const a=s&&r.online,i=Ei(e,a?r.id:null),l=(r.features??[]).includes("battery-operated"),u=o&&l&&!r.disabled,p=Di(e,u?r.id:null);return!s&&!u?null:c("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[u&&p&&t(Ri,{status:p}),s&&t(Li,{deviceName:r.name,snapshotUrl:i.src,status:n})]})}var Et=288,Gr=196,Tt=8;function Li({deviceName:e,snapshotUrl:r,status:n}){const s=z(null),[o,a]=k(null),i=n==="offline"||n==="disabled",l=()=>{const p=s.current;if(!p)return;const m=p.getBoundingClientRect(),g=m.top,f=window.innerHeight-m.bottom,h=g<Gr+Tt&&f>g,b=h?m.bottom+Tt:m.top-Gr-Tt,v=m.right-Et,x=Math.max(8,Math.min(v,window.innerWidth-Et-8));a({top:b,left:x,placeBelow:h})},u=()=>a(null);return c(ge,{children:[t("button",{ref:s,type:"button",onClick:p=>p.stopPropagation(),onMouseEnter:l,onMouseLeave:u,onFocus:l,onBlur:u,className:"flex h-6 w-6 items-center justify-center rounded text-foreground-subtle hover:bg-surface-hover hover:text-foreground transition-colors flex-shrink-0",title:"Preview","aria-label":"Preview snapshot",children:t(xt,{className:"h-3.5 w-3.5"})}),o&&ht(c("div",{style:{position:"fixed",top:o.top,left:o.left,width:Et,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[t("div",{className:"h-40 bg-background flex items-center justify-center",children:r&&!i?t("img",{src:r,alt:e,className:"h-full w-full object-cover"}):t("span",{className:"text-xs text-foreground-subtle",children:n==="offline"?"Offline — no snapshot":n==="disabled"?"Disabled":"No snapshot yet"})}),t("div",{className:"px-3 py-2",children:t("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function ks({status:e}){const r=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",n=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return t("span",{className:w("h-1.5 w-1.5 rounded-full flex-shrink-0",r),title:n})}function Zt(e){const{trpc:r,device:n,parent:s,integrationIcon:o,onNavigate:a,className:i}=e,l=oi(e),u=e.variant??"compact",p=e.view??"card",m=!n.disabled,g=n.isCamera??n.type.toLowerCase()==="camera",f=e.children??[],h=f.filter(Br),b=f.filter(A=>!Br(A)),v=f.length>0,[x,y]=k(!1),C=e.expanded??x,S=e.onToggleExpand??(()=>y(A=>!A)),E=A=>{a?.(A)},P=e.indentLevel??(e.isAccessoryRow?2:0),M=m?n.online?"online":"offline":"disabled";return p==="table"?t(Oi,{trpc:r,device:n,variant:u,flags:l,parent:s??null,integrationIcon:o??null,accessoryCount:h.length,adoptedCount:b.length,hasChildren:v,expanded:C,onToggleExpand:S,onNavigate:E,displayStatus:M,isCamera:g,showSnapshot:l.showSnapshot&&g,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:P,className:i}):c("div",{className:w("rounded-lg border border-border bg-surface transition-colors",!m&&"opacity-60",i),children:[c("div",{onClick:()=>E(n.id),className:w("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",u==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[t(Cs,{device:n,variant:u,flags:l,parent:s??null,integrationIcon:o??null,hasChildren:v,expanded:C,onToggleExpand:S,onNavigateToParent:E}),t(ws,{trpc:r,device:n,flags:l,accessoryCount:h.length,adoptedCount:b.length,showFeatureRow:!1}),t(Ss,{trpc:r,device:n,status:M,enabled:l.showSnapshot&&g,showStatusPills:!0}),t(ys,{trpc:r,device:n,flags:l}),t(ks,{status:M})]}),C&&v&&t(di,{trpc:r,accessoryChildren:h,adoptedChildren:b,onNavigate:E})]})}var _i={0:"pl-2",1:"pl-6",2:"pl-8"};function Oi(e){const{trpc:r,device:n,variant:s,flags:o,parent:a,integrationIcon:i,accessoryCount:l,adoptedCount:u,hasChildren:p,expanded:m,onToggleExpand:g,onNavigate:f,displayStatus:h,isCamera:b,showSnapshot:v,isAccessoryRow:x,indentLevel:y,className:C}=e;return c("tr",{onClick:()=>f(n.id),className:w("cursor-pointer hover:bg-surface-hover transition-colors",!o.showChildrenAccordion&&"border-b border-border-subtle/40",x&&"bg-foreground-subtle/[0.03]",C),children:[t("td",{className:w("py-2 align-middle pr-2",_i[y]),children:t(Cs,{device:n,variant:s,flags:o,parent:a,integrationIcon:i,hasChildren:p,expanded:m,onToggleExpand:g,onNavigateToParent:f})}),t("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:n.type}),t("td",{className:"px-2 py-2 align-middle",children:t(ws,{trpc:r,device:n,flags:o,accessoryCount:l,adoptedCount:u,showFeatureRow:!0})}),t("td",{className:"px-2 py-2 align-middle",children:t(Ss,{trpc:r,device:n,status:h,enabled:v&&b,showStatusPills:!0})}),t("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:c("span",{className:"inline-flex items-center gap-1.5",children:[t(ys,{trpc:r,device:n,flags:o}),t(ks,{status:h})]})})]})}function Bi(e,r){const[n,s]=k(e);return G(()=>{const o=setTimeout(()=>s(e),r);return()=>clearTimeout(o)},[e,r]),n}var $i=new Set(["hub","nvr"]);function Qi(e){const r=new Map;for(const o of e)r.set(o.id,o);const n=[],s=new Map;for(const o of e){const a=o.parentDeviceId;if(a==null){n.push(o);continue}const i=r.get(a);if(!i){n.push(o);continue}const l=o.role!==null&&o.role!==void 0;if($i.has(i.type)&&!l){n.push(o);continue}const p=s.get(a);p?p.push(o):s.set(a,[o])}return{topLevel:n,accessoriesByParent:s}}var jr=2;function Gi(e,r){if(r<=1)return[{kind:"page",n:1}];if(r<=7){const a=[];for(let i=1;i<=r;i++)a.push({kind:"page",n:i});return a}const n=[],s=Math.max(2,e-jr),o=Math.min(r-1,e+jr);n.push({kind:"page",n:1}),s>2&&n.push({kind:"ellipsis",side:"left"});for(let a=s;a<=o;a++)n.push({kind:"page",n:a});return o<r-1&&n.push({kind:"ellipsis",side:"right"}),n.push({kind:"page",n:r}),n}function ji({currentPage:e,totalItems:r,pageSize:n,onPageChange:s,itemNoun:o="devices"}){if(r<=n)return null;const a=Math.ceil(r/n),i=(e-1)*n+1,l=Math.min(e*n,r),u=Gi(e,a);return c("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[c("span",{children:["Showing ",i,"–",l," of ",r," ",o]}),c("span",{className:"inline-flex items-center gap-1",children:[t("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>s(e-1),className:w("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:t(Pn,{className:"h-3 w-3"})}),u.map((p,m)=>{if(p.kind==="ellipsis")return t("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${m}`);const g=p.n===e;return t("button",{type:"button",onClick:()=>s(p.n),className:w("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",g?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:p.n},`p-${p.n}`)}),t("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>s(e+1),className:w("inline-flex items-center justify-center h-7 w-7 rounded border border-border bg-surface text-foreground-subtle","hover:text-foreground hover:bg-surface-hover transition-colors","disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-surface"),children:t(Le,{className:"h-3 w-3"})})]})]})}function Fi({view:e,onViewChange:r,types:n,currentType:s,onTypeChange:o,addons:a,currentAddon:i,onAddonChange:l,hideAddons:u=!1}){return c("div",{className:"flex items-center gap-2 flex-wrap",children:[c("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[t("button",{type:"button",onClick:()=>r("cards"),className:w("inline-flex items-center justify-center h-7 w-8 transition-colors",e==="cards"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Cards view",children:t(Lo,{className:"h-3.5 w-3.5"})}),t("button",{type:"button",onClick:()=>r("table"),className:w("inline-flex items-center justify-center h-7 w-8 border-l border-border transition-colors",e==="table"?"bg-primary/10 text-primary":"bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-label":"Table view",children:t(_o,{className:"h-3.5 w-3.5"})})]}),n&&n.length>0&&c(ge,{children:[t(Fr,{children:"Type"}),t(It,{active:s===null,onClick:()=>o(null),children:"All"}),n.map(p=>t(It,{active:s===p,onClick:()=>o(s===p?null:p),children:zi(p)},p))]}),!u&&a&&a.length>0&&c(ge,{children:[t(Fr,{children:"Integration"}),a.map(p=>t(It,{active:i===p.id,icon:p.icon,onClick:()=>l(i===p.id?null:p.id),showClearIcon:i===p.id,children:p.name},p.id))]})]})}function Fr({children:e}){return t("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function It({active:e,icon:r,onClick:n,showClearIcon:s,children:o}){return c("button",{type:"button",onClick:n,className:w("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors",e?"border-primary/40 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:[r&&t("span",{className:"inline-flex items-center",children:r}),t("span",{children:o}),e&&s&&t(Ce,{className:"h-2.5 w-2.5 opacity-70"})]})}function zi(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function Wi({variant:e,onClearFilters:r}){return c("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t(Oo,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),t("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&r&&t("button",{type:"button",onClick:r,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function De(e,r){if(e==="root")return r;switch(r){case"view":return"deviceView";case"page":return"devicePage";case"type":return"deviceType";case"q":return"deviceQ";case"addon":return"deviceAddon"}}function zr(e){try{const r=localStorage.getItem(`camstack:${e}:lastFilters`);if(!r)return{};const n=JSON.parse(r);return typeof n!="object"||n===null?{}:n}catch{return{}}}function Ui(e,r){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(r))}catch{}}function Wr(e,r,n){const s=new URLSearchParams(window.location.search),o=s.get(De(e,"view")),a=o==="cards"||o==="table"?o:n.view??r,i=s.get(De(e,"page")),l=i?parseInt(i,10):1,u=Number.isFinite(l)&&l>=1?l:1,p=s.get(De(e,"addon"))??n.addon??null,m=s.get(De(e,"type"))??n.type??null,g=s.get(De(e,"q"))??n.q??"";return{view:a,page:u,addon:p,type:m,q:g}}function Hi(e,r,n){const s=new URLSearchParams(window.location.search),o=(l,u)=>{u===null||u===""?s.delete(l):s.set(l,u)};o(De(e,"view"),r.view===n?null:r.view),o(De(e,"page"),r.page===1?null:String(r.page)),o(De(e,"addon"),r.addon),o(De(e,"type"),r.type),o(De(e,"q"),r.q||null);const a=s.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function qi(e){const{scope:r,defaultView:n,lsKey:s}=e,[o,a]=k(()=>{const b=zr(s);return Wr(r,n,b)}),i=z(o);i.current=o,G(()=>{const b=()=>{const v=zr(s),x=Wr(r,n,v);i.current=x,a(x)};return window.addEventListener("popstate",b),()=>window.removeEventListener("popstate",b)},[r,n,s]);const l=D(b=>{const v=b(i.current);i.current=v,a(v),Hi(r,v,n),Ui(s,{view:v.view,addon:v.addon,type:v.type,q:v.q})},[r,n,s]),u=D(b=>l(v=>({...v,view:b})),[l]),p=D(b=>l(v=>({...v,page:b})),[l]),m=D(b=>l(v=>({...v,addon:b,page:1})),[l]),g=D(b=>l(v=>({...v,type:b,page:1})),[l]),f=D(b=>l(v=>({...v,q:b,page:1})),[l]),h=D(()=>l(b=>({...b,addon:null,type:null,q:"",page:1})),[l]);return{state:o,setView:u,setPage:p,setAddon:m,setType:g,setQ:f,clearFilters:h}}var Vi={cards:24,table:50};function Tu(e){const{devices:r,trpc:n,defaultView:s="table",filters:o,forceAddon:a,resolveIntegrationIcon:i,resolveParent:l,onNavigate:u,pageSize:p=Vi,urlScope:m="root",lsKey:g=m==="root"?"devices":"integrations:nested"}=e,f=qi({scope:m,defaultView:s,lsKey:g}),h=f.state.view,b=h==="cards"?p.cards:p.table,[v,x]=k(f.state.q),y=Bi(v,300);G(()=>{y!==f.state.q&&f.setQ(y)},[y]);const C=a??f.state.addon,S=U(()=>{const ee=f.state.q.toLowerCase().trim();return r.filter(ie=>!(C&&ie.addonId!==C||f.state.type&&ie.type!==f.state.type||ee&&!ie.name.toLowerCase().includes(ee)&&!ie.stableId.toLowerCase().includes(ee)))},[r,C,f.state.type,f.state.q]),E=U(()=>Qi(S),[S]),P=U(()=>{if(f.state.q.trim()==="")return new Set;const ee=f.state.q.toLowerCase().trim(),ie=new Set;for(const[fe,te]of E.accessoriesByParent.entries())te.some(X=>X.name.toLowerCase().includes(ee)||X.stableId.toLowerCase().includes(ee))&&ie.add(fe);return ie},[E.accessoriesByParent,f.state.q]),M=E.topLevel.length,A=Math.max(1,Math.ceil(M/b)),R=Math.min(f.state.page,A),$=(R-1)*b,q=E.topLevel.slice($,$+b);G(()=>{R!==f.state.page&&f.setPage(R)},[R]),el();const V=C!=null||f.state.type!==null||f.state.q!=="",he=M===0;return c("div",{className:"flex flex-col gap-3",children:[c("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[t(Fi,{view:h,onViewChange:f.setView,types:o?.types,currentType:f.state.type,onTypeChange:f.setType,addons:o?.addons,currentAddon:f.state.addon,onAddonChange:f.setAddon,hideAddons:a!==void 0}),c("div",{className:"relative",children:[t(Ye,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),t("input",{type:"text",value:v,onChange:ee=>x(ee.target.value),placeholder:"Search by name or stableId","aria-label":"Search devices by name or stableId",className:"h-7 pl-7 pr-2.5 rounded-md border border-border bg-surface text-[11px] text-foreground placeholder:text-foreground-subtle/60 focus:outline-none focus:ring-1 focus:ring-primary/40 w-56"})]})]}),he?t(Wi,{variant:V?"filtered":"nofilter",onClearFilters:V?f.clearFilters:void 0}):h==="cards"?t(Ki,{rows:q,accessoriesByParent:E.accessoriesByParent,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:u??null}):t(Ji,{rows:q,accessoriesByParent:E.accessoriesByParent,autoExpandedParents:P,devices:S,trpc:n,resolveIntegrationIcon:i??null,resolveParent:l??null,onNavigate:u??null}),t(ji,{currentPage:R,totalItems:M,pageSize:b,onPageChange:f.setPage}),a===void 0&&V&&M>0&&c("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",M," of ",r.length," devices",C&&c(ge,{children:[" ","· filtered by"," ",t("strong",{className:"text-primary",children:o?.addons?.find(ee=>ee.id===C)?.name??C})]})]})]})}function Ki({rows:e,accessoriesByParent:r,trpc:n,resolveIntegrationIcon:s,resolveParent:o,onNavigate:a}){return t("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(i=>{const l=r.get(i.id)??[];return t(Zt,{trpc:n,device:i,view:"card",integrationIcon:s?.(i.addonId)??null,parent:i.parentDeviceId!==null?o?.(i.parentDeviceId)??null:null,children:l,onNavigate:a??void 0},i.id)})})}var Zi=new Set(["hub","nvr"]);function Yi(e,r){return e.parentDeviceId===null||r===null?0:Zi.has(r.toLowerCase())?1:0}function Ji({rows:e,accessoriesByParent:r,autoExpandedParents:n,devices:s,trpc:o,resolveIntegrationIcon:a,resolveParent:i,onNavigate:l}){const u=U(()=>{const p=new Map;for(const m of s)p.set(m.id,m.type);return p},[s]);return t("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:c("table",{className:"w-full border-collapse",children:[t("thead",{children:c("tr",{className:"border-b border-border",children:[t("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),t("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),t("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),t("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),t("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),t("tbody",{children:e.map(p=>{const m=r.get(p.id)??[],g=m.length>0,f=n.has(p.id),h=p.parentDeviceId!==null?i?.(p.parentDeviceId)??null:null,b=p.parentDeviceId!==null?u.get(p.parentDeviceId)??null:null;return t(Xi,{parent:p,accessories:m,hasAccessories:g,forceExpanded:f,trpc:o,integrationIcon:a?.(p.addonId)??null,parentRowParent:h,indentLevel:Yi(p,b),onNavigate:l??null},p.id)})})]})})}function Xi({parent:e,accessories:r,hasAccessories:n,forceExpanded:s,trpc:o,integrationIcon:a,parentRowParent:i,indentLevel:l,onNavigate:u}){const[p,m]=k(s),g=z(s);return G(()=>{g.current!==s&&(m(s),g.current=s)},[s]),c(ge,{children:[t(Zt,{trpc:o,device:e,view:"table",integrationIcon:a,parent:i,children:r,onNavigate:u??void 0,showChildrenAccordion:n,expanded:p,onToggleExpand:()=>m(b=>!b),indentLevel:l}),n&&p&&r.map(b=>t(Zt,{trpc:o,device:b,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:u??void 0},b.id))]})}function el(){tr()}function Iu({options:e,value:r,onChange:n}){return t("div",{className:"flex flex-wrap gap-2",children:e.map(s=>{const o=s.id===r;return c("button",{onClick:()=>s.available&&n(s.id),disabled:!s.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${o?"border-primary/40 bg-primary/10 text-primary":s.available?"border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground":"border-border/40 bg-surface/40 text-foreground-subtle/40 cursor-not-allowed"}`,children:[t(So,{className:"h-3.5 w-3.5 shrink-0"}),s.label,s.isBest&&c("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-400",children:[t(ko,{className:"h-2.5 w-2.5"}),"Best"]}),s.platformScore!=null&&c("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",s.platformScore,")"]}),t("span",{className:`h-1.5 w-1.5 rounded-full ${s.available?"bg-success":"bg-danger"}`})]},s.id)})})}function tl(e,r){const n=new Set(r.slots.flatMap(i=>i.addons.map(l=>l.id))),s=[];function o(i){if(!n.has(i.addonId))return s.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const l=r.slots.flatMap(m=>m.addons).find(m=>m.id===i.addonId);let u=i.modelId;if(l&&!l.models.some(m=>m.id===u)){const m=l.defaultModelId;s.push(`Model "${u}" not available for ${i.addonId} — using "${m}"`),u=m}const p=i.children.map(m=>o(m)).filter(m=>m!==null);return{...i,modelId:u,children:p}}const a=e.map(i=>o(i)).filter(i=>i!==null);return{valid:s.length===0,steps:a,warnings:s}}function rl(e){const r=new Map;for(const n of e.slots)for(const s of n.addons)r.set(s.id,s);return r}function Rt(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Lt({addon:e,onClick:r}){return t("button",{type:"button",onClick:r,className:"w-full rounded-lg border border-dashed border-border/60 px-3 py-2.5 text-left transition-all hover:border-primary/30 hover:bg-surface/60 group",children:c("div",{className:"flex items-center gap-3",children:[t($o,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),c("div",{className:"flex-1 min-w-0",children:[t("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),c("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(n=>t("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/8 text-blue-400/50",children:n},n)),e.inputClasses.length>0&&e.outputClasses.length>0&&t("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(n=>t("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/8 text-green-400/50",children:n},n))]})]})]})})}function Ru({schema:e,steps:r,onChange:n,templates:s,selectedTemplateId:o,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:l,onDeleteTemplate:u,readOnly:p=!1,excludeAddons:m=[],hideTemplates:g=!1,showOnlyEnabled:f=!1,showSlotLabels:h=!1,toggleMode:b="simple",overrides:v={},onOverrideChange:x,inheritedEnabledByAddon:y={},hideModelAndSettings:C=!1}){const S=L=>({toggleMode:b,hideModelAndSettings:C,...b==="threeState"?{overrideState:v[L]!==void 0?v[L]:null,onOverrideChange:x?_=>x(L,_):void 0,inheritedEnabled:y[L]}:{}}),E=U(()=>new Set(m),[m]),P=U(()=>rl(e),[e]),[M,A]=k([]),R=o?JSON.stringify(r)!==JSON.stringify(s.find(L=>L.id===o)?.steps):!1;function $(L){const _=L.target.value||null;if(_){const J=s.find(W=>W.id===_);if(J){const W=tl(J.steps,e);A([...W.warnings])}}else A([]);a(_)}function q(){o&&l(o,r)}function V(){const L=window.prompt("Template name:");L?.trim()&&i(L.trim(),r)}function he(){if(!o)return;const L=s.find(_=>_.id===o);L&&window.confirm(`Delete template "${L.name}"?`)&&u(o)}function ee(L){n(r.map(_=>_.addonId!==L.addonId?_:ie(L)))}function ie(L){const _=L.children.some(J=>J.enabled||J.children.some(W=>W.enabled));return{...L,enabled:L.enabled||_,children:L.children.map(J=>{const W=J.children.some(re=>re.enabled);return{...J,enabled:J.enabled||W}})}}function fe(L,_){const J=Rt(_);n(r.map(W=>W.addonId!==L?W:{...W,children:[...W.children,J]}))}function te(L){const _=new Set;for(const J of L){_.add(J.addonId);for(const re of J.children)_.add(re.addonId);const W=te(J.children);for(const re of W)_.add(re)}return _}const X=te(r);function Z(L){const _=P.get(L.addonId);if(!_)return[];const W=e.slots.find(Y=>Y.id===_.slot)?.parentSlot==null,re=_.childSlots,ne=new Set(L.children.map(Y=>Y.addonId)),j=[];for(const Y of e.slots)if(re.includes(Y.id))for(const se of Y.addons){if(ne.has(se.id)||E.has(se.id))continue;const ve=se.inputClasses.length===0;if(ve&&!W)continue;(ve||se.inputClasses.some(H=>L.outputClasses.includes(H)))&&j.push(se)}return j}function ae(L){const _=f?{...L,children:L.children.filter(W=>W.enabled).map(W=>({...W,children:W.children.filter(re=>re.enabled)}))}:L,J=f?[]:Z(_);return c("div",{className:"space-y-1.5",children:[t(Pt,{step:_,schema:P.get(_.addonId)??null,allSchemas:P,onChange:ee,onDelete:p?void 0:W=>n(r.filter(re=>re.addonId!==W)),readOnly:p,...S(_.addonId)}),(_.children.length>0||J.length>0)&&c("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[h&&t("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),_.children.map(W=>{const re=Z(W);return c("div",{className:"space-y-1.5",children:[t(Pt,{step:W,schema:P.get(W.addonId)??null,allSchemas:P,depth:1,onChange:ne=>{ee({..._,children:_.children.map(j=>j.addonId===ne.addonId?ne:j)})},onDelete:p?void 0:ne=>{ee({..._,children:_.children.filter(j=>j.addonId!==ne)})},readOnly:p,...S(W.addonId)}),(W.children.length>0||re.length>0)&&c("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[h&&t("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),W.children.map(ne=>t(Pt,{step:ne,schema:P.get(ne.addonId)??null,allSchemas:P,depth:2,onChange:j=>{ee({..._,children:_.children.map(Y=>Y.addonId===W.addonId?{...Y,children:Y.children.map(se=>se.addonId===j.addonId?j:se)}:Y)})},onDelete:p?void 0:j=>{ee({..._,children:_.children.map(Y=>Y.addonId===W.addonId?{...Y,children:Y.children.filter(se=>se.addonId!==j)}:Y)})},readOnly:p,...S(ne.addonId)},ne.addonId)),!p&&re.map(ne=>t(Lt,{addon:ne,onClick:()=>{const j=Rt(ne);ee({..._,children:_.children.map(Y=>Y.addonId===W.addonId?{...Y,children:[...Y.children,j]}:Y)})}},ne.id))]})]},W.addonId)}),!p&&J.map(W=>t(Lt,{addon:W,onClick:()=>fe(_.addonId,W)},W.id))]})]},_.addonId)}const pe=e.slots.filter(L=>L.parentSlot===null).sort((L,_)=>L.priority-_.priority);return c("div",{className:"space-y-4",children:[!g&&t("div",{className:"rounded-lg border border-border bg-surface p-3",children:c("div",{className:"flex items-center gap-2",children:[t("div",{className:"relative flex-1 min-w-0",children:c("select",{value:o??"",onChange:$,className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/50",children:[t("option",{value:"",children:"No template"}),s.map(L=>t("option",{value:L.id,children:L.name},L.id))]})}),R&&t("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),t("button",{onClick:q,disabled:!o||p,title:"Save",className:w("p-2 rounded-lg border border-border transition-colors",o&&!p?"text-foreground-subtle hover:bg-surface-hover":"text-foreground-subtle/30 cursor-not-allowed"),children:t(No,{className:"h-4 w-4"})}),t("button",{onClick:V,disabled:p,title:"Save As",className:w("p-2 rounded-lg border border-border transition-colors",p?"text-foreground-subtle/30 cursor-not-allowed":"text-foreground-subtle hover:bg-surface-hover"),children:t(Co,{className:"h-4 w-4"})}),t("button",{onClick:he,disabled:!o||p,title:"Delete",className:w("p-2 rounded-lg border border-border transition-colors",o&&!p?"text-foreground-subtle hover:text-danger":"text-foreground-subtle/30 cursor-not-allowed"),children:t(Ie,{className:"h-4 w-4"})})]})}),M.length>0&&c("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[c("div",{className:"flex items-center justify-between",children:[t("span",{className:"font-medium",children:"Template loaded with warnings:"}),t("button",{onClick:()=>A([]),className:"text-amber-400/60 hover:text-amber-400",children:t(Ce,{className:"h-3.5 w-3.5"})})]}),M.map((L,_)=>c("div",{children:["• ",L]},_))]}),pe.map(L=>{const _=r.filter(j=>j.slot===L.id&&!E.has(j.addonId)),J=f?_.filter(j=>j.enabled):_,W=f?[]:L.addons.filter(j=>!X.has(j.id)&&!E.has(j.id)),re=new Map,ne=[];for(const j of J)j.group?(re.has(j.group)||re.set(j.group,[]),re.get(j.group).push(j)):ne.push(j);return c("div",{className:"space-y-2",children:[h&&c("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",L.label]}),ne.map(j=>ae(j)),[...re.entries()].map(([j,Y])=>c("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[t("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:j}),Y.map(se=>ae(se))]},j)),!p&&W.map(j=>t(Lt,{addon:j,onClick:()=>{n([...r,Rt(j)])}},j.id))]},L.id)})]})}var rt={person:"#3b82f6",vehicle:"#f59e0b",animal:"#22c55e",face:"#a855f7",plate:"#ec4899",bird:"#14b8a6",dog:"#84cc16",cat:"#f97316",car:"#f59e0b",truck:"#d97706",bus:"#b45309",motorcycle:"#eab308",bicycle:"#ca8a04",motion:"#facc15"},Ur=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],nl="#f59e42";function Me(e,r){if(r?.[e])return r[e];if(r?.[e.toLowerCase()])return r[e.toLowerCase()];if(rt[e])return rt[e];if(rt[e.toLowerCase()])return rt[e.toLowerCase()];let n=0;for(let s=0;s<e.length;s++)n=n*31+(e.codePointAt(s)??0)>>>0;return Ur[n%Ur.length]??nl}function Lu({src:e,imageWidth:r,imageHeight:n,detections:s=[],classColors:o,aspectRatio:a,className:i,placeholder:l,showConfidence:u=!0,minConfidence:p=0,borderWidth:m=2}){function g(y){return Me(y,o)}const f=a??(r&&n?`${r}/${n}`:"16/9"),h=s.filter(y=>y.score>=p),b=h.filter(y=>y.kind==="first-level"),v=h.filter(y=>y.kind==="detail"),x=al(v,y=>y.parentId??"");return t("div",{className:w("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:f},children:e?c(ge,{children:[t("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),h.map((y,C)=>y.debug?.mask&&y.debug.maskWidth&&y.debug.maskHeight?t(sl,{mask:y.debug.mask,maskWidth:y.debug.maskWidth,maskHeight:y.debug.maskHeight,bbox:y.bbox,imageWidth:r,imageHeight:n,color:g(y.macroClass)},`mask-${C}`):null),b.map(y=>{const C=x.get(y.id)??[];return t(Hr,{detection:y,imageWidth:r,imageHeight:n,color:g(y.macroClass),showConfidence:u,borderWidth:y.debug?.mask?1:m,children:C.map(S=>t(ol,{child:S,parentBbox:y.bbox,color:g(S.macroClass),showConfidence:u},`child-${S.id}`))},`det-${y.id}`)}),v.filter(y=>!y.parentId||!b.some(C=>C.id===y.parentId)).map(y=>t(Hr,{detection:y,imageWidth:r,imageHeight:n,color:g(y.macroClass),showConfidence:u,borderWidth:m},`orphan-${y.id}`))]}):t("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:l??"No image loaded"})})}function Hr({detection:e,imageWidth:r,imageHeight:n,color:s,showConfidence:o,borderWidth:a,children:i}){const{x:l,y:u,width:p,height:m}=e.bbox,g=c("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[c("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:s},children:[e.macroClass,o&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((f,h)=>c("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:Me(f.label)},children:[f.label," ",(f.score*100).toFixed(0),"%"]},`${e.id}-lbl-${h}`))]});return c("div",{className:"absolute rounded-sm",style:{left:`${l/r*100}%`,top:`${u/n*100}%`,width:`${p/r*100}%`,height:`${m/n*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:s},children:[g,i]})}function sl({mask:e,maskWidth:r,maskHeight:n,bbox:s,imageWidth:o,imageHeight:a,color:i}){const l=z(null);return G(()=>{const u=l.current;if(!u)return;const p=u.getContext("2d");if(!p)return;const m=atob(e),g=new Uint8Array(m.length);for(let y=0;y<m.length;y++)g[y]=m.charCodeAt(y);const f=parseInt(i.slice(1,3),16),h=parseInt(i.slice(3,5),16),b=parseInt(i.slice(5,7),16);u.width=r,u.height=n;const v=p.createImageData(r,n),x=r*n;for(let y=0;y<x;y++){const C=y<g.length?g[y]:0,S=y*4;C>0&&(v.data[S]=f,v.data[S+1]=h,v.data[S+2]=b,v.data[S+3]=120)}p.putImageData(v,0,0)},[e,r,n,i]),t("canvas",{ref:l,className:"absolute pointer-events-none",style:{left:`${s.x/o*100}%`,top:`${s.y/a*100}%`,width:`${s.width/o*100}%`,height:`${s.height/a*100}%`,imageRendering:"pixelated"}})}function ol({child:e,parentBbox:r,color:n,showConfidence:s}){if(r.width<=0||r.height<=0)return null;const o=(e.bbox.x-r.x)/r.width*100,a=(e.bbox.y-r.y)/r.height*100,i=e.bbox.width/r.width*100,l=e.bbox.height/r.height*100;return t("div",{className:"absolute rounded-sm",style:{left:`${Math.max(0,o)}%`,top:`${Math.max(0,a)}%`,width:`${Math.min(100,i)}%`,height:`${Math.min(100,l)}%`,borderWidth:"1px",borderStyle:"solid",borderColor:n},children:c("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[c("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((u,p)=>c("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:Me(u.label)},children:[u.label," ",(u.score*100).toFixed(0),"%"]},`${e.id}-lbl-${p}`))]})})}function al(e,r){const n=new Map;for(const s of e){const o=r(s),a=n.get(o)??[];a.push(s),n.set(o,a)}return n}function _u({detections:e,classColors:r,className:n,hiddenKeys:s,onToggleVisibility:o}){const a=r;if(e.length===0)return t("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(m=>m.kind==="first-level"),l=e.filter(m=>m.kind==="detail"),u=new Map;for(const m of l){if(!m.parentId)continue;const g=u.get(m.parentId)??[];g.push(m),u.set(m.parentId,g)}const p=l.filter(m=>!m.parentId||!i.some(g=>g.id===m.parentId));return c("div",{className:n,children:[c("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),c("div",{className:"space-y-2",children:[i.map(m=>t(qr,{detection:m,children_:u.get(m.id)??[],colors:a,hiddenKeys:s,onToggleVisibility:o},m.id)),p.map(m=>t(qr,{detection:m,children_:[],colors:a,hiddenKeys:s,onToggleVisibility:o},m.id))]})]})}function qr({detection:e,children_:r,colors:n,hiddenKeys:s,onToggleVisibility:o}){const a=Me(e.macroClass,n),i=!s?.has(e.id),l=e.debug?.mask,u=e.debug?.maskWidth,p=e.debug?.maskHeight,m=e.debug?.alternateLabels;return c("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[c("div",{className:"flex justify-between items-center",children:[c("div",{className:"flex items-center gap-2",children:[o&&t("input",{type:"checkbox",checked:i,onChange:()=>o(e.id,!i),className:"h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0"}),t("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),t("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&t("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),l&&u&&p&&c("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",u,"x",p]})]}),t(cl,{confidence:e.score})]}),c("div",{className:"text-[10px] text-foreground-subtle font-mono",children:["bbox: [",Math.round(e.bbox.x),", ",Math.round(e.bbox.y),","," ",Math.round(e.bbox.x+e.bbox.width),","," ",Math.round(e.bbox.y+e.bbox.height),"]"]}),e.labels.length>0&&t("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((g,f)=>c("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:Me(g.label,n)+"20",color:Me(g.label,n)},children:[g.label,c("span",{className:"opacity-60",children:[(g.score*100).toFixed(0),"%"]}),g.detectionId&&c("span",{className:"opacity-40 text-[8px]",children:["→ ",g.detectionId]})]},f))}),m&&Object.keys(m).length>0&&t(ll,{alternateLabels:m,colors:n}),r.length>0&&t(il,{items:r,colors:n,hiddenKeys:s,onToggleVisibility:o})]})}function il({items:e,colors:r,hiddenKeys:n,onToggleVisibility:s}){return t("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(o=>{const a=Me(o.macroClass,r),i=!n?.has(o.id),l=o.debug?.mask,u=o.debug?.maskWidth,p=o.debug?.maskHeight;return c("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[c("div",{className:"flex items-center gap-1.5",children:[s&&t("input",{type:"checkbox",checked:i,onChange:()=>s(o.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),t("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),t("span",{className:"font-medium",style:{color:a},children:o.macroClass}),c("span",{className:"text-foreground-subtle",children:[(o.score*100).toFixed(0),"%"]}),l&&u&&p&&c("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",u,"x",p]})]}),o.labels.length>0&&t("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:o.labels.map((m,g)=>c("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:Me(m.label,r)+"20",color:Me(m.label,r)},children:[m.label," ",c("span",{className:"opacity-60",children:[(m.score*100).toFixed(0),"%"]})]},g))})]},o.id)})})}function ll({alternateLabels:e,colors:r}){const[n,s]=k(!1),o=Object.keys(e);return c("div",{className:"mt-1",children:[c("button",{onClick:()=>s(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[t("span",{className:`transition-transform ${n?"rotate-90":""}`,children:"▶"}),"Alternates (",o.length," source",o.length!==1?"s":"",")"]}),n&&t("div",{className:"mt-1 ml-3 space-y-1.5",children:o.map(a=>{const i=e[a];return!i||i.length===0?null:c("div",{children:[t("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),t("div",{className:"flex flex-wrap gap-1",children:i.map((l,u)=>c("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:Me(a,r)+"10",color:Me(a,r),opacity:Math.max(.4,l.score)},children:[l.label,c("span",{className:"opacity-60",children:[(l.score*100).toFixed(1),"%"]})]},u))})]},a)})})]})}function cl({confidence:e}){const r=e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger";return c("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${r}`,children:[(e*100).toFixed(1),"%"]})}function Ou({timings:e,totalMs:r,className:n}){const s=Object.entries(e);return s.length===0&&r===void 0?null:c("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??""}`,children:[t("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),c("div",{className:"space-y-1 text-xs",children:[s.map(([o,a])=>c("div",{className:"flex justify-between",children:[t("span",{className:"text-foreground-subtle",children:o}),c("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},o)),r!==void 0&&c("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[t("span",{children:"Total"}),c("span",{className:"font-mono",children:[r.toFixed(1),"ms"]})]})]})]})}function Bu({images:e,selectedFilename:r,uploadedName:n,onSelect:s,onUpload:o,className:a,accept:i="image/*",uploadLabel:l="Upload..."}){const u=()=>{const p=document.createElement("input");p.type="file",p.accept=i,p.onchange=()=>{const m=p.files?.[0];if(!m)return;const g=new FileReader;g.onload=()=>{const f=g.result,h=f.split(",")[1];h&&o(h,m.name,f)},g.readAsDataURL(m)},p.click()};return c("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(p=>t("button",{onClick:()=>s(p.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${r===p.filename?"bg-primary text-primary-foreground border-primary":"bg-surface border-border text-foreground hover:border-primary/50"}`,children:p.id??p.filename.replace(/\.[^.]+$/,"")},p.filename)),t("button",{onClick:u,className:"px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors",children:l}),n&&t("span",{className:"text-xs text-foreground-subtle",children:n})]})}var nt="w-full px-3 py-2 text-sm rounded-md border border-border bg-surface text-foreground focus:outline-none focus:ring-2 focus:ring-primary/50";function $u({runtime:e,backend:r,modelId:n,agentId:s="hub",runtimes:o,backends:a,models:i,agents:l=[],onRuntimeChange:u,onBackendChange:p,onModelChange:m,onAgentChange:g,layout:f="grid",className:h,showAgent:b=!1}){return c("div",{className:`${f==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":f==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${h??""}`,children:[b&&l.length>0&&c("label",{className:"space-y-1",children:[t("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),t("select",{value:s,onChange:x=>g?.(x.target.value),className:nt,children:l.map(x=>c("option",{value:x.id,children:[x.name," (",x.status,")"]},x.id))})]}),c("label",{className:"space-y-1",children:[t("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),t("select",{value:e,onChange:x=>u(x.target.value),className:nt,children:o.map(x=>c("option",{value:x.value,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.value))})]}),c("label",{className:"space-y-1",children:[t("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),t("select",{value:r,onChange:x=>p(x.target.value),className:nt,children:a.map(x=>c("option",{value:x.id,disabled:!x.available,children:[x.label,x.available?"":" (unavailable)"]},x.id))})]}),c("label",{className:"space-y-1",children:[t("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),t("select",{value:n,onChange:x=>m(x.target.value),className:nt,children:i.length===0?t("option",{value:"",children:"No compatible models"}):i.map(x=>c("option",{value:x.id,children:[x.name,x.downloaded?" ✓":""]},x.id))})]})]})}function dl({className:e}){return c("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[t("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),t("circle",{cx:"12",cy:"12",r:"3"})]})}function ul({className:e}){return c("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[t("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),t("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),t("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),t("path",{d:"m2 2 20 20"})]})}function pl({className:e}){return t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:t("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function ml({onLogin:e,serverUrl:r,logoSrc:n,error:s,className:o}){const[a,i]=k(""),[l,u]=k(""),[p,m]=k(!1),[g,f]=k(!1),[h,b]=k(null),v=s??h,x=async y=>{if(y.preventDefault(),!g){b(null),f(!0);try{await e(a,l)}catch(C){const S=C instanceof Error?C.message:"Login failed. Please try again.";b(S)}finally{f(!1)}}};return t("div",{className:w("flex min-h-screen items-center justify-center bg-background p-4",o),children:c("div",{className:"w-full max-w-sm",children:[n&&t("div",{className:"flex justify-center mb-8",children:t("img",{src:n,alt:"Logo",className:"h-12"})}),r&&t("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:r}),c("form",{onSubmit:x,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[v&&t("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:v}),c("div",{className:"space-y-1.5",children:[t("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),t("input",{type:"text",value:a,onChange:y=>i(y.target.value),autoComplete:"username",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"})]}),c("div",{className:"space-y-1.5",children:[t("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),c("div",{className:"relative",children:[t("input",{type:p?"text":"password",value:l,onChange:y=>u(y.target.value),autoComplete:"current-password",required:!0,className:"w-full rounded-lg border border-border bg-background px-3 py-2.5 pr-10 text-sm text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary"}),t("button",{type:"button",onClick:()=>m(y=>!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:p?t(ul,{className:"h-4 w-4"}):t(dl,{className:"h-4 w-4"})})]})]}),c("button",{type:"submit",disabled:g,className:"w-full rounded-lg bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[g&&t(pl,{className:"h-4 w-4 animate-spin"}),g?"Logging in...":"Log in"]})]})]})})}var Yt="camstack_dev_token",Ms=Te(null);function Qu(){const e=we(Ms);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function gl(){return typeof window>"u"?null:localStorage.getItem(Yt)}function fl({className:e}){return c("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[t("circle",{cx:"12",cy:"12",r:"4"}),t("path",{d:"M12 2v2"}),t("path",{d:"M12 20v2"}),t("path",{d:"m4.93 4.93 1.41 1.41"}),t("path",{d:"m17.66 17.66 1.41 1.41"}),t("path",{d:"M2 12h2"}),t("path",{d:"M20 12h2"}),t("path",{d:"m6.34 17.66-1.41 1.41"}),t("path",{d:"m19.07 4.93-1.41 1.41"})]})}function hl({className:e}){return t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:t("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function bl({children:e,serverUrl:r,title:n,token:s,onLogout:o}){const a=ta(),i=U(()=>{const f=r.replace(/^http/,"ws")+"/trpc",h=qs({url:f,connectionParams:()=>({token:s})});return[Vs({condition:b=>b.type==="subscription",true:Ks({client:h,transformer:Ft}),false:gn({url:`${r}/trpc`,transformer:Ft,headers:()=>({authorization:`Bearer ${s}`})})})]},[r,s]),l=U(()=>mn({links:i}),[i]),u=U(()=>d.createClient({links:i}),[i]),p=U(()=>Ro({serverUrl:r,token:s}),[r,s]);G(()=>(p.init().catch(()=>{}),()=>{p.close()}),[p]);const m=U(()=>new Us,[]),g=U(()=>({trpc:l,token:s,logout:o}),[l,s,o]);return t(Wa,{system:p,children:t(d.Provider,{client:u,queryClient:m,children:t(Hs,{client:m,children:t(Ms.Provider,{value:g,children:c("div",{className:"min-h-screen bg-background text-foreground",children:[c("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[c("div",{className:"flex items-center gap-2",children:[t("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),n&&t("span",{className:"text-sm font-medium text-foreground",children:n}),t("span",{className:"text-xs text-foreground-subtle",children:r})]}),c("div",{className:"flex items-center gap-2",children:[c("button",{type:"button",onClick:a.toggleMode,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:`Theme: ${a.mode}`,children:[a.resolvedMode==="dark"?t(fl,{className:"h-3.5 w-3.5"}):t(hl,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),t("button",{type:"button",onClick:o,className:"rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors",children:"Logout"})]})]}),t("div",{className:"p-4",children:e({trpc:l,theme:a})})]})})})})})}function vl({children:e,serverUrl:r="https://localhost:4443",title:n}){const[s,o]=k(gl),a=D(async(l,u)=>{const g=await mn({links:[gn({url:`${r}/trpc`,transformer:Ft})]}).auth.login.mutate({username:l,password:u});if(!g.token)throw new Error("No token returned");localStorage.setItem(Yt,g.token),o(g.token)},[r]),i=D(()=>{localStorage.removeItem(Yt),o(null)},[]);return s?t(Mr,{children:t(bl,{serverUrl:r,title:n,token:s,onLogout:i,children:e})}):t(Mr,{children:t(ml,{onLogin:a,serverUrl:r})})}function Gu(e,r={}){const{serverUrl:n="https://localhost:4443",title:s,rootId:o="root"}=r,a=document.getElementById(o);if(!a){console.error(`[mountAddonPage] Element #${o} not found`);return}zs(a).render(br(vl,{serverUrl:n,title:s,children:({trpc:i,theme:l})=>br(e,{trpc:i,theme:{isDark:l.resolvedMode==="dark"},navigate:u=>{console.log("[dev] navigate:",u)}})}))}var Ps=Be("camstack:custom-field-renderers",{});function ju({renderers:e,children:r}){return t(Ps.Provider,{value:e,children:r})}function xl(e){return we(Ps)[e]??null}var pr=Be("camstack:device-context",null);function Fu({deviceId:e,device:r,children:n}){const s={deviceId:e,device:r??null};return t(pr.Provider,{value:s,children:n})}function yl(){return we(pr)?.deviceId??null}function zu(){return we(pr)?.device??null}var Wu=d.accessories.getStatus.useQuery,Uu=d.addonPages.listPages.useQuery,Hu=d.addons.list.useQuery,qu=d.addons.getLogs.useQuery,Vu=d.addons.listPackages.useQuery,Ku=d.addons.installPackage.useMutation,Zu=d.addons.installFromWorkspace.useMutation,Yu=d.addons.isWorkspaceAvailable.useQuery,Ju=d.addons.listWorkspacePackages.useQuery,Xu=d.addons.uninstallPackage.useMutation,ep=d.addons.reloadPackages.useMutation,tp=d.addons.searchAvailable.useQuery,rp=d.addons.listUpdates.useQuery,np=d.addons.updatePackage.useMutation,sp=d.addons.forceRefresh.useMutation,op=d.addons.restartServer.useMutation,ap=d.addons.getVersions.useQuery,ip=d.addons.restartAddon.useMutation,lp=d.addons.getAutoUpdateSettings.useQuery,cp=d.addons.setAutoUpdateSettings.useMutation,dp=d.addons.getAddonAutoUpdate.useQuery,up=d.addons.setAddonAutoUpdate.useMutation,pp=d.addons.applyAutoUpdateToAll.useMutation,mp=d.addons.custom.useMutation,gp=d.addons.onAddonLogs.useSubscription,fp=d.addonSettings.getGlobalSettings.useQuery,hp=d.addonSettings.updateGlobalSettings.useMutation,bp=d.addonSettings.getDeviceSettings.useQuery,vp=d.addonSettings.updateDeviceSettings.useMutation,wl=d.addonWidgets.listWidgets.useQuery,xp=d.alerts.emit.useMutation,yp=d.alerts.update.useMutation,wp=d.alerts.list.useQuery,Np=d.alerts.getUnreadCount.useQuery,Cp=d.alerts.markRead.useMutation,Sp=d.alerts.markAllRead.useMutation,kp=d.alerts.dismiss.useMutation,Mp=d.audioAnalysis.resolveDeviceSettings.useQuery,Pp=d.audioAnalysis.getDeviceSettingsContribution.useQuery,Ap=d.audioAnalysis.getDeviceLiveContribution.useQuery,Dp=d.audioAnalysis.applyDeviceSettingsPatch.useMutation,Ep=d.audioAnalyzer.analyseChunk.useMutation,Tp=d.audioAnalyzer.classify.useQuery,Ip=d.audioAnalyzer.isReady.useQuery,Rp=d.audioAnalyzer.dispose.useMutation,Lp=d.audioAnalyzer.reprobeAudioEngine.useMutation,_p=d.audioCodec.listSupportedCodecs.useQuery,Op=d.audioCodec.canHandle.useQuery,Bp=d.audioCodec.createDecodeSession.useMutation,$p=d.audioCodec.createEncodeSession.useMutation,Qp=d.audioCodec.closeSession.useMutation,Gp=d.audioCodec.pushEncodedFrame.useMutation,jp=d.audioCodec.pullPcm.useQuery,Fp=d.audioCodec.pushPcm.useMutation,zp=d.audioCodec.pullEncoded.useQuery,Wp=d.audioCodec.flushEncode.useMutation,Up=d.audioCodec.listActiveSessions.useQuery,Hp=d.audioMetrics.getCurrentSnapshot.useQuery,qp=d.audioMetrics.getHistory.useQuery,Vp=d.backup.trigger.useMutation,Kp=d.backup.list.useQuery,Zp=d.backup.restore.useMutation,Yp=d.backup.delete.useMutation,Jp=d.battery.getStatus.useQuery,Xp=d.brightness.setBrightness.useMutation,em=d.brightness.getStatus.useQuery,tm=d.cameraStreams.getCameraStreams.useQuery,rm=d.cameraStreams.getBrokerStreams.useQuery,nm=d.cameraStreams.getRtspEntries.useQuery,sm=d.decoder.supportsCodec.useQuery,om=d.decoder.getInfo.useQuery,am=d.decoder.createSession.useQuery,im=d.decoder.destroySession.useQuery,lm=d.decoder.pushPacket.useQuery,cm=d.decoder.openStream.useQuery,dm=d.decoder.pullFrames.useQuery,um=d.decoder.updateConfig.useQuery,pm=d.decoder.getStats.useQuery,mm=d.decoder.listActiveSessions.useQuery,gm=d.decoder.reprobeHwaccel.useMutation,fm=d.detectionPipeline.getDeviceSettingsContribution.useQuery,hm=d.detectionPipeline.getDeviceLiveContribution.useQuery,bm=d.detectionPipeline.applyDeviceSettingsPatch.useMutation,vm=d.deviceDiscovery.listDiscovered.useQuery,xm=d.deviceDiscovery.refreshDiscovery.useMutation,ym=d.deviceDiscovery.adoptDevice.useMutation,wm=d.deviceDiscovery.releaseDevice.useMutation,Nm=d.deviceDiscovery.getStatus.useQuery,Cm=d.deviceManager.allocateDeviceId.useMutation,Sm=d.deviceManager.registerDevice.useMutation,km=d.deviceManager.removeDevice.useMutation,Mm=d.deviceManager.persistConfig.useMutation,Pm=d.deviceManager.loadConfig.useQuery,Am=d.deviceManager.loadRuntimeState.useQuery,Dm=d.deviceManager.loadMeta.useQuery,Em=d.deviceManager.setName.useMutation,Tm=d.deviceManager.setLocation.useMutation,Im=d.deviceManager.setMetadata.useMutation,Rm=d.deviceManager.listLocations.useQuery,Lm=d.deviceManager.addLocation.useMutation,_m=d.deviceManager.removeLocation.useMutation,Om=d.deviceManager.setDisabled.useMutation,Bm=d.deviceManager.listPersistedByAddon.useQuery,$m=d.deviceManager.listAll.useQuery,Qm=d.deviceManager.getDevice.useQuery,Gm=d.deviceManager.getChildren.useQuery,jm=d.deviceManager.getStreamSources.useQuery,Fm=d.deviceManager.getConfigSchema.useQuery,zm=d.deviceManager.getSettingsSchema.useQuery,Wm=d.deviceManager.updateConfig.useMutation,Um=d.deviceManager.enable.useMutation,Hm=d.deviceManager.disable.useMutation,qm=d.deviceManager.remove.useMutation,Vm=d.deviceManager.getStreamProfileMap.useQuery,Km=d.deviceManager.setStreamProfileMap.useMutation,Zm=d.deviceManager.probeStreams.useMutation,Ym=d.deviceManager.getBindings.useQuery,Jm=d.deviceManager.getAllBindings.useQuery,Xm=d.deviceManager.setWrapperActive.useMutation,eg=d.deviceManager.listWrappersForCap.useQuery,tg=d.deviceManager.listBindableCapsForDeviceType.useQuery,rg=d.deviceManager.getDeviceSettingsAggregate.useQuery,ng=d.deviceManager.getDeviceLiveInfoAggregate.useQuery,sg=d.deviceManager.getDeviceAggregate.useQuery,og=d.deviceManager.updateDeviceField.useMutation,ag=d.deviceManager.updateDeviceFieldsBatch.useMutation,ig=d.deviceManager.discoverDevices.useMutation,lg=d.deviceManager.adoptDevice.useMutation,cg=d.deviceManager.getCreationSchema.useQuery,dg=d.deviceManager.createDevice.useMutation,ug=d.deviceManager.testCreationField.useMutation,pg=d.deviceManager.testField.useMutation,mg=d.deviceManager.getDeviceStatusAggregate.useQuery,gg=d.deviceOps.getStreamSources.useQuery,fg=d.deviceOps.getConfigEntries.useQuery,hg=d.deviceOps.setConfig.useMutation,bg=d.deviceOps.removeDevice.useMutation,vg=d.deviceOps.getSettingsSchema.useQuery,xg=d.deviceProvider.start.useMutation,yg=d.deviceProvider.stop.useMutation,wg=d.deviceProvider.getStatus.useQuery,Ng=d.deviceProvider.getDevices.useQuery,Cg=d.deviceProvider.supportsDiscovery.useQuery,Sg=d.deviceProvider.discoverDevices.useMutation,kg=d.deviceProvider.adoptDiscoveredDevice.useMutation,Mg=d.deviceProvider.supportsManualCreation.useQuery,Pg=d.deviceProvider.getChildCreationSchema.useQuery,Ag=d.deviceProvider.createDevice.useMutation,Dg=d.deviceProvider.testCreationField.useMutation,Eg=d.deviceState.getSnapshot.useQuery,Tg=d.deviceState.getCapSlice.useQuery,Ig=d.deviceState.getAllSnapshots.useQuery,Rg=d.deviceState.setCapSlice.useMutation,Lg=d.doorbell.getStatus.useQuery,_g=d.events.getEvents.useQuery,Og=d.events.getEventThumbnail.useQuery,Bg=d.events.getEventClipUrl.useQuery,$g=d.integrations.list.useQuery,Qg=d.integrations.get.useQuery,Gg=d.integrations.getByAddonId.useQuery,jg=d.integrations.create.useMutation,Fg=d.integrations.update.useMutation,zg=d.integrations.delete.useMutation,Wg=d.integrations.getSettings.useQuery,Ug=d.integrations.setSettings.useMutation,Hg=d.integrations.getAvailableTypes.useQuery,qg=d.integrations.testConnection.useMutation,Vg=d.intercom.startSession.useMutation,Kg=d.intercom.handleAnswer.useMutation,Zg=d.intercom.stopSession.useMutation,Yg=d.intercom.getStatus.useQuery,Jg=d.metricsProvider.collectSnapshot.useQuery,Xg=d.metricsProvider.getCached.useQuery,ef=d.metricsProvider.getCurrent.useQuery,tf=d.metricsProvider.getDiskSpace.useQuery,rf=d.metricsProvider.getGpuInfo.useQuery,nf=d.metricsProvider.getCpuTemperature.useQuery,sf=d.metricsProvider.getProcessStats.useQuery,of=d.metricsProvider.listAddonInstances.useQuery,af=d.metricsProvider.getAddonStats.useQuery,lf=d.metricsProvider.listNodeProcesses.useQuery,cf=d.metricsProvider.killProcess.useMutation,df=d.motion.isDetected.useQuery,uf=d.motion.getStatus.useQuery,pf=d.motionDetection.analyze.useMutation,mf=d.motionDetection.removeCamera.useMutation,gf=d.motionDetection.reset.useMutation,ff=d.motionDetection.getDeviceSettingsContribution.useQuery,hf=d.motionDetection.getDeviceLiveContribution.useQuery,bf=d.motionDetection.applyDeviceSettingsPatch.useMutation,vf=d.motionTrigger.setMotionTrigger.useMutation,xf=d.motionTrigger.getStatus.useQuery,yf=d.nativeObjectDetection.getStatus.useQuery,wf=d.networkQuality.getDeviceStats.useQuery,Nf=d.networkQuality.getAllStats.useQuery,Cf=d.networkQuality.reportClientStats.useMutation,Sf=d.nodes.topology.useQuery,kf=d.nodes.deployAddon.useMutation,Mf=d.nodes.undeployAddon.useMutation,Pf=d.nodes.restartAddon.useMutation,Af=d.nodes.restartProcess.useMutation,Df=d.nodes.restartNode.useMutation,Ef=d.nodes.shutdownNode.useMutation,Tf=d.nodes.renameNode.useMutation,If=d.nodes.clusterAddonStatus.useQuery,Rf=d.nodes.setProcessLogLevel.useMutation,Lf=d.nodes.executeQuery.useMutation,_f=d.notificationOutput.send.useMutation,Of=d.notificationOutput.sendTest.useMutation,Bf=d.osd.setOverlay.useMutation,$f=d.osd.getStatus.useQuery,Qf=d.pipelineAnalytics.getActiveTracks.useQuery,Gf=d.pipelineAnalytics.getTrack.useQuery,jf=d.pipelineAnalytics.listTracks.useQuery,Ff=d.pipelineAnalytics.clearTracks.useMutation,zf=d.pipelineAnalytics.getMotionEvents.useQuery,Wf=d.pipelineAnalytics.getObjectEvents.useQuery,Uf=d.pipelineAnalytics.getAudioEvents.useQuery,Hf=d.pipelineAnalytics.getEventMedia.useQuery,qf=d.pipelineAnalytics.getTrackMedia.useQuery,Vf=d.pipelineAnalytics.getDeviceSettingsContribution.useQuery,Kf=d.pipelineAnalytics.getDeviceLiveContribution.useQuery,Zf=d.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Yf=d.pipelineExecutor.getAvailableEngines.useQuery,Jf=d.pipelineExecutor.getSelectedEngine.useQuery,Xf=d.pipelineExecutor.getDefaultSteps.useQuery,eh=d.pipelineExecutor.reprobeEngine.useMutation,th=d.pipelineExecutor.getVideoPipelineSteps.useQuery,rh=d.pipelineExecutor.setVideoPipelineSteps.useMutation,nh=d.pipelineExecutor.getSchema.useQuery,sh=d.pipelineExecutor.getGlobalSteps.useQuery,oh=d.pipelineExecutor.getGlobalPipelineConfig.useQuery,ah=d.pipelineExecutor.getOrchestratorConfigSchema.useQuery,ih=d.pipelineExecutor.listTemplates.useQuery,lh=d.pipelineExecutor.saveTemplate.useMutation,ch=d.pipelineExecutor.updateTemplate.useMutation,dh=d.pipelineExecutor.deleteTemplate.useMutation,uh=d.pipelineExecutor.getCapabilities.useQuery,ph=d.pipelineExecutor.getAddonModels.useQuery,mh=d.pipelineExecutor.downloadModel.useMutation,gh=d.pipelineExecutor.deleteModel.useMutation,fh=d.pipelineExecutor.detect.useQuery,hh=d.pipelineExecutor.runPipeline.useMutation,bh=d.pipelineExecutor.runPipelineBatch.useMutation,vh=d.pipelineExecutor.cacheFrameInPool.useMutation,xh=d.pipelineExecutor.inferCached.useMutation,yh=d.pipelineExecutor.uncacheFrame.useMutation,wh=d.pipelineExecutor.getEffectiveTuning.useQuery,Nh=d.pipelineExecutor.listLoadedEngines.useQuery,Ch=d.pipelineExecutor.spinEngine.useMutation,Sh=d.pipelineExecutor.killEngine.useMutation,kh=d.pipelineExecutor.listReferenceImages.useQuery,Mh=d.pipelineExecutor.getReferenceImage.useQuery,Ph=d.pipelineExecutor.getReferenceAudioFiles.useQuery,Ah=d.pipelineExecutor.getReferenceAudio.useQuery,Dh=d.pipelineExecutor.getAudioCapabilities.useQuery,Eh=d.pipelineExecutor.runAudioTest.useMutation,Th=d.pipelineExecutor.getDetectionConfigSchema.useQuery,Ih=d.pipelineOrchestrator.assignPipeline.useMutation,Rh=d.pipelineOrchestrator.unassignPipeline.useMutation,Lh=d.pipelineOrchestrator.rebalance.useMutation,_h=d.pipelineOrchestrator.getPipelineAssignments.useQuery,Oh=d.pipelineOrchestrator.getPipelineAssignment.useQuery,Bh=d.pipelineOrchestrator.getAgentLoad.useQuery,$h=d.pipelineOrchestrator.getGlobalMetrics.useQuery,Qh=d.pipelineOrchestrator.getCameraMetrics.useQuery,Gh=d.pipelineOrchestrator.getCapabilityBindings.useQuery,jh=d.pipelineOrchestrator.setCapabilityBinding.useMutation,Fh=d.pipelineOrchestrator.assignDecoder.useMutation,zh=d.pipelineOrchestrator.unassignDecoder.useMutation,Wh=d.pipelineOrchestrator.getDecoderAssignments.useQuery,Uh=d.pipelineOrchestrator.assignAudio.useMutation,Hh=d.pipelineOrchestrator.unassignAudio.useMutation,qh=d.pipelineOrchestrator.getAudioAssignment.useQuery,Vh=d.pipelineOrchestrator.getAudioNodeLoad.useQuery,Kh=d.pipelineOrchestrator.getAudioAssignments.useQuery,Zh=d.pipelineOrchestrator.getDecoderAssignment.useQuery,Yh=d.pipelineOrchestrator.getAgentSettings.useQuery,Jh=d.pipelineOrchestrator.listAgentSettings.useQuery,Xh=d.pipelineOrchestrator.setAgentAddonDefaults.useMutation,eb=d.pipelineOrchestrator.removeAgentSettings.useMutation,tb=d.pipelineOrchestrator.getCameraSettings.useQuery,rb=d.pipelineOrchestrator.setCameraStepToggle.useMutation,nb=d.pipelineOrchestrator.getCameraStepOverrides.useQuery,sb=d.pipelineOrchestrator.setCameraStepOverride.useMutation,ob=d.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,ab=d.pipelineOrchestrator.resolvePipeline.useQuery,ib=d.pipelineOrchestrator.listTemplates.useQuery,lb=d.pipelineOrchestrator.saveTemplate.useMutation,cb=d.pipelineOrchestrator.updateTemplate.useMutation,db=d.pipelineOrchestrator.deleteTemplate.useMutation,ub=d.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,pb=d.pipelineOrchestrator.getDeviceLiveContribution.useQuery,mb=d.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,gb=d.pipelineRunner.attachCamera.useMutation,fb=d.pipelineRunner.detachCamera.useMutation,hb=d.pipelineRunner.reportMotion.useMutation,bb=d.pipelineRunner.getLocalLoad.useQuery,vb=d.pipelineRunner.getLocalMetrics.useQuery,xb=d.pipelineRunner.getCameraMetrics.useQuery,yb=d.pipelineRunner.getAllCameraMetrics.useQuery,wb=d.pipelineRunner.getLocalCameras.useQuery,Nb=d.platformProbe.getCapabilities.useQuery,Cb=d.platformProbe.getHardware.useQuery,Sb=d.platformProbe.resolveInferenceConfig.useQuery,kb=d.platformProbe.resolveHwAccel.useQuery,Mb=d.ptz.move.useMutation,Pb=d.ptz.continuousMove.useMutation,Ab=d.ptz.stop.useMutation,Db=d.ptz.getPresets.useQuery,Eb=d.ptz.goToPreset.useMutation,Tb=d.ptz.goHome.useMutation,Ib=d.ptz.getPosition.useQuery,Rb=d.ptz.getStatus.useQuery,Lb=d.ptzAutotrack.getStatus.useQuery,_b=d.ptzAutotrack.setEnabled.useMutation,Ob=d.ptzAutotrack.getSettings.useQuery,Bb=d.ptzAutotrack.setSettings.useMutation,$b=d.reboot.reboot.useMutation,Qb=d.recording.getSegments.useQuery,Gb=d.recording.getPlaybackUrl.useQuery,jb=d.recording.getThumbnailAt.useQuery,Fb=d.recordingEngine.getStatus.useQuery,zb=d.recordingEngine.enable.useMutation,Wb=d.recordingEngine.disable.useMutation,Ub=d.recordingEngine.getConfig.useQuery,Hb=d.recordingEngine.updateConfig.useMutation,qb=d.recordingEngine.getPlaylist.useQuery,Vb=d.recordingEngine.getThumbnail.useQuery,Kb=d.recordingEngine.getSegments.useQuery,Zb=d.recordingEngine.getAvailability.useQuery,Yb=d.recordingEngine.estimateStorage.useQuery,Jb=d.recordingEngine.estimateGlobalStorage.useQuery,Xb=d.recordingEngine.getStorageUsage.useQuery,ev=d.recordingEngine.setPolicy.useMutation,tv=d.recordingEngine.getPolicy.useQuery,rv=d.recordingEngine.getPolicyStatus.useQuery,nv=d.recordingEngine.getRetentionConfig.useQuery,sv=d.recordingEngine.updateRetentionConfig.useMutation,ov=d.recordingEngine.getMotionStats.useQuery,av=d.settingsStore.get.useQuery,iv=d.settingsStore.set.useMutation,lv=d.settingsStore.query.useQuery,cv=d.settingsStore.insert.useMutation,dv=d.settingsStore.update.useMutation,uv=d.settingsStore.delete.useMutation,pv=d.settingsStore.count.useQuery,mv=d.settingsStore.isEmpty.useQuery,gv=d.settingsStore.declareCollection.useMutation,fv=d.snapshot.getSnapshot.useQuery,hv=d.snapshot.invalidateCache.useMutation,bv=d.snapshot.getStatus.useQuery,vv=d.snapshot.getDeviceSettingsContribution.useQuery,xv=d.snapshot.getDeviceLiveContribution.useQuery,yv=d.snapshot.applyDeviceSettingsPatch.useMutation,wv=d.snapshotProvider.supportsDevice.useQuery,Nv=d.snapshotProvider.getSnapshot.useQuery,Cv=d.storage.resolve.useQuery,Sv=d.storage.write.useMutation,kv=d.storage.read.useQuery,Mv=d.storage.exists.useQuery,Pv=d.storage.list.useQuery,Av=d.storage.delete.useMutation,Dv=d.storage.getAvailableSpace.useQuery,Ev=d.streamBroker.publishCameraStream.useMutation,Tv=d.streamBroker.retractCameraStream.useMutation,Iv=d.streamBroker.assignProfile.useMutation,Rv=d.streamBroker.unassignProfile.useMutation,Lv=d.streamBroker.listAllCameraStreams.useQuery,_v=d.streamBroker.listAllProfileSlots.useQuery,Ov=d.streamBroker.getBrokerStats.useQuery,Bv=d.streamBroker.listClients.useQuery,$v=d.streamBroker.killClient.useMutation,Qv=d.streamBroker.restartProfile.useMutation,Gv=d.streamBroker.getStreamUrl.useQuery,jv=d.streamBroker.getBroker.useQuery,Fv=d.streamBroker.setPreBufferDuration.useMutation,zv=d.streamBroker.getPreBufferInfo.useQuery,Wv=d.streamBroker.getRtspPort.useQuery,Uv=d.streamBroker.getAllRtspEntries.useQuery,Hv=d.streamBroker.getRtspEntry.useQuery,qv=d.streamBroker.regenerateRtspToken.useMutation,Vv=d.streamBroker.setRtspEnabled.useMutation,Kv=d.streamBroker.isRtspEnabled.useQuery,Zv=d.streamBroker.getDeviceSettingsContribution.useQuery,Yv=d.streamBroker.getDeviceLiveContribution.useQuery,Jv=d.streamBroker.applyDeviceSettingsPatch.useMutation,Xv=d.switch.setState.useMutation,ex=d.switch.getStatus.useQuery,tx=d.system.info.useQuery,rx=d.system.health.useQuery,nx=d.system.featureFlags.useQuery,sx=d.system.networkAddresses.useQuery,ox=d.system.getRetentionConfig.useQuery,ax=d.system.setRetentionConfig.useMutation,ix=d.system.forceRetentionCleanup.useMutation,lx=d.toast.onToast.useSubscription,cx=d.turnProvider.getTurnServers.useQuery,dx=d.userManagement.listUsers.useQuery,ux=d.userManagement.createUser.useMutation,px=d.userManagement.updateUser.useMutation,mx=d.userManagement.deleteUser.useMutation,gx=d.userManagement.resetPassword.useMutation,fx=d.userManagement.validateCredentials.useMutation,hx=d.userManagement.listApiKeys.useQuery,bx=d.userManagement.createApiKey.useMutation,vx=d.userManagement.revokeApiKey.useMutation,xx=d.userManagement.validateApiKey.useMutation,yx=d.userManagement.createScopedToken.useMutation,wx=d.userManagement.revokeScopedToken.useMutation,Nx=d.userManagement.validateScopedToken.useQuery,Cx=d.userManagement.listScopedTokens.useQuery,Sx=d.webrtcSession.listStreams.useQuery,kx=d.webrtcSession.createSession.useMutation,Mx=d.webrtcSession.handleAnswer.useMutation,Px=d.webrtcSession.closeSession.useMutation,Ax=d.webrtcSession.hasAdaptiveBitrate.useQuery,Dx=d.zoneAnalytics.getCurrentSnapshot.useQuery,Ex=d.zoneAnalytics.getZoneHistory.useQuery,Tx=d.zoneAnalytics.getCameraHistory.useQuery,Ix=d.zoneAnalytics.getUnzonedHistory.useQuery,Rx=d.zoneRules.listRules.useQuery,Lx=d.zoneRules.setRules.useMutation,_x=d.zones.listZones.useQuery,Ox=d.zones.addZone.useMutation,Bx=d.zones.removeZone.useMutation,$x=d.zones.updateZone.useMutation,As=Be("camstack:widget-registry",null),ft=new Map,st=new Map,Vr=new Set;function Nl(e){if(!e||typeof e!="object")return!1;const r=e.default;return r!==null&&typeof r=="object"}function Cl(e){if(!e||typeof e!="object")return typeof e;const r=e,n=Object.getPrototypeOf(r),s=n&&typeof n=="object"?n.constructor?.name:void 0;return{ownKeys:Object.keys(r),allKeys:Object.getOwnPropertyNames(r),proto:typeof s=="string"?s:void 0}}async function Sl(e,r){const n=ft.get(e);if(n)return n;const s=st.get(e);if(s)return s;Vr.has(e)||(ca(),pt.registerRemotes([{name:e,entry:r,type:"module"}],{force:!1}),Vr.add(e));const o=pt.loadRemote(`${e}/widgets`).then(a=>{if(!Nl(a)){const l=Cl(a);throw new Error(`Widget remote ${e} (${r}) does not expose a default record on './widgets'. Got: ${JSON.stringify(l)}`)}const i=a.default;return ft.set(e,i),st.delete(e),i}).catch(a=>{throw st.delete(e),a});return st.set(e,o),o}var kl=3e4,Ml=2e3;function Qx({children:e}){const r=tr(),n=z(Date.now()),{data:s}=wl(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const u=l.state.data;return u&&u.length>0||Date.now()-n.current>=kl?!1:Ml}});yt("addon.widget-ready",()=>{r.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[o,a]=k(0);G(()=>{if(!s)return;let l=!1;const u=new Set;for(const p of s){if(u.has(p.remoteName)||(u.add(p.remoteName),ft.has(p.remoteName)))continue;const m=p.bundleUrl;Sl(p.remoteName,m).then(()=>{l||a(g=>g+1)}).catch(g=>{const f=g instanceof Error?g.message:String(g);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:p.remoteName,entryUrl:m,reason:f})})}return()=>{l=!0}},[s]);const i=U(()=>{const l=s??[],u=new Map;for(const m of l)u.set(`${m.addonId}/${m.stableId}`,m);const p=(m,g)=>({widgetId:m,addonId:g.addonId,stableId:g.stableId,label:g.label,description:g.description,icon:g.icon,remoteName:g.remoteName,bundleUrl:g.bundleUrl,hosts:g.hosts,requires:g.requires,defaultSize:g.defaultSize,allowedSizes:g.allowedSizes,defaultColumns:g.defaultColumns,defaultRows:g.defaultRows});return{resolve:m=>{const g=u.get(m);if(!g)return;const f=ft.get(g.remoteName);if(!f)return null;const h=f[g.stableId];if(h)return h},metadata:m=>{const g=u.get(m);if(g)return p(m,g)},listAll:()=>{const m=[];for(const[g,f]of u)m.push(p(g,f));return m}}},[s,o]);return t(As.Provider,{value:i,children:e})}function Pl(e){return mr().resolve(e)}function Al(e){return mr().metadata(e)}function Gx(){return mr().listAll()}function mr(){const e=Dl();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function Dl(){return El(As)}function El(e){return we(e)}function Tl(e){const{widgetId:r,host:n="device-tab",config:s,deviceId:o,integrationId:a,instanceId:i,size:l,columns:u,rows:p}=e,m=Pl(r),g=Al(r),f=U(()=>i??r,[i,r]);if(m===void 0&&g===void 0)return t(ot,{widgetId:r,reason:"unknown"});if(m===void 0)return t(ot,{widgetId:r,reason:"missing-export"});if(m===null)return t(Il,{});if(g){if(g.requires.deviceContext&&o===void 0)return t(ot,{widgetId:r,reason:"missing-device-context"});if(g.requires.integrationContext&&a===void 0)return t(ot,{widgetId:r,reason:"missing-integration-context"})}return t(m,{instanceId:f,host:n,config:s,deviceId:o,integrationId:a,size:l,columns:u,rows:p})}function Il(){return c("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[t("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),t("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),t("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function ot({widgetId:e,reason:r}){const n=r==="unknown"?`Widget "${e}" not registered`:r==="missing-export"?`Widget "${e}" bundle does not export this stableId`:r==="missing-device-context"?`Widget "${e}" requires a deviceId`:`Widget "${e}" requires an integrationId`;return t("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:n})}var Ge="w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none disabled:opacity-50 disabled:cursor-not-allowed",Nt="block text-[11px] font-medium text-foreground mb-1",Rl="text-[10px] text-foreground-subtle mt-0.5";function ye({label:e,description:r,required:n,span:s,children:o,translationFn:a}){const i=s===2?"col-span-2":s===3?"col-span-3":s===4?"col-span-4":"col-span-1",l=Re(e,a),u=Re(r,a);return c("div",{className:i,children:[l!==void 0&&l!==""&&c("label",{className:Nt,children:[l,n&&t("span",{className:"text-danger ml-0.5",children:"*"})]}),o,u&&t("p",{className:Rl,children:u})]})}function Ll({field:e,value:r,onChange:n,disabled:s,translationFn:o}){return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:t("input",{type:e.inputType??"text",className:Ge,value:r==null?"":String(r),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:s||e.disabled,onChange:a=>n(a.target.value)})})}function _l({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const[a,i]=k(r==null?"":String(r)),l=z(!1);G(()=>{if(l.current)return;const p=r==null?"":String(r);i(p)},[r]);const u=p=>{if(i(p),p===""||p==="-"){n(void 0);return}const m=Number(p);Number.isNaN(m)||n(m)};return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("div",{className:"flex items-center gap-1",children:[t("input",{type:"number",className:Ge,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:s||e.disabled,onFocus:()=>{l.current=!0},onBlur:()=>{l.current=!1},onChange:p=>u(p.target.value)}),e.unit&&t("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function Ol({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const a=!!r,i=s||e.disabled;return e.style==="checkbox"?t(ye,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[t("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",checked:a,disabled:i,onChange:l=>n(l.target.checked)}),t("span",{className:"text-xs font-medium text-foreground",children:Re(e.label,o)}),e.required&&t("span",{className:"text-danger",children:"*"})]})}):t(ye,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("div",{className:"flex items-center justify-between",children:[c("span",{className:Nt+" mb-0",children:[Re(e.label,o),e.required&&t("span",{className:"text-danger ml-0.5",children:"*"})]}),t("button",{type:"button",role:"switch","aria-checked":a,disabled:i,onClick:()=>!i&&n(!a),className:["relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150",a?"bg-primary":"bg-foreground-subtle/30",i?"opacity-50 cursor-not-allowed":"cursor-pointer"].join(" "),children:t("span",{className:["inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150",a?"translate-x-4":"translate-x-0.5"].join(" ")})})]})})}function Bl({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const a=e.options.some(i=>i.value==="");return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("select",{className:Ge,value:r==null?"":String(r),disabled:s||e.disabled,onChange:i=>n(i.target.value),children:[!e.required&&!a&&t("option",{value:"",children:"— Select —"}),e.options.map(i=>t("option",{value:i.value,children:i.label},i.value))]})})}function $l({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const a=Array.isArray(r)?r:[],i=l=>{if(a.includes(l))n(a.filter(u=>u!==l));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;n([...a,l])}};return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:t("div",{className:"flex flex-wrap gap-2",children:e.options.map(l=>{const u=a.includes(l.value);return c("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",u?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",s||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[t("input",{type:"checkbox",className:"sr-only",checked:u,disabled:s||e.disabled,onChange:()=>i(l.value)}),l.label]},l.value)})})})}function Ql({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const[a,i]=k(!1),l=e.showToggle!==!1;return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("div",{className:"relative",children:[t("input",{type:a?"text":"password",className:Ge+(l?" pr-9":""),value:r==null?"":String(r),placeholder:e.placeholder,disabled:s||e.disabled,onChange:u=>n(u.target.value)}),l&&t("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,onClick:()=>i(u=>!u),children:a?t(Mn,{className:"h-3.5 w-3.5"}):t(xt,{className:"h-3.5 w-3.5"})})]})})}function Gl({field:e,value:r,onChange:n,disabled:s,translationFn:o}){return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:t("textarea",{className:Ge+" resize-y min-h-[60px]",value:r==null?"":String(r),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:s||e.disabled,onChange:a=>n(a.target.value)})})}function jl({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const a=r==null,i=e.nullable===!0,l=a?e.default??e.min:Number(r),u=e.showValue!==!1,p=e.nullLabel??"Auto",m=s||e.disabled,g=e.displayScale??1,f=e.min/g,h=e.max/g,b=l/g,v=(e.step??1)/g;if(i&&a)return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-xs text-foreground-subtle hover:border-primary/40 hover:text-primary transition-colors text-left",disabled:m,onClick:()=>n(e.default??e.min),children:[p," — click to set manually"]})});const x=e.showStepper===!0&&u,y=S=>{const E=l+S*(e.step??1),P=Math.min(e.max,Math.max(e.min,E));P!==l&&n(P)},C="flex h-6 w-6 shrink-0 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:cursor-not-allowed disabled:opacity-40";return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[c("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[t("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:f}),t("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:f,max:h,step:v,value:b,disabled:m,onChange:S=>n(Number(S.target.value)*g)}),t("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h})]}),(u||i||e.unit)&&c("div",{className:"flex shrink-0 items-center gap-2",children:[x&&t("button",{type:"button",className:C,disabled:m||l<=e.min,onClick:()=>y(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:t(To,{className:"h-3 w-3"})}),u&&t("input",{type:"number",className:"w-16 rounded border border-border bg-surface px-1.5 py-0.5 text-xs text-center text-foreground tabular-nums focus:outline-none focus:ring-1 focus:ring-primary",min:f,max:h,step:v,value:b,disabled:m,onChange:S=>{if(S.target.value===""){n(i?null:e.min);return}const E=Number(S.target.value)*g,P=e.step??1,M=E-e.min,A=e.min+Math.round(M/P)*P;n(Math.min(e.max,Math.max(e.min,A)))}}),x&&t("button",{type:"button",className:C,disabled:m||l>=e.max,onClick:()=>y(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:t(ar,{className:"h-3 w-3"})}),e.unit&&t("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&t("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${p}`,disabled:m,onClick:()=>n(null),children:p})]})]})})}function Fl({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const a=Array.isArray(r)?r:[],[i,l]=k(""),u=z(null),p=D(h=>{const b=h.trim();!b||a.includes(b)||e.maxTags!==void 0&&a.length>=e.maxTags||(n([...a,b]),l(""))},[a,e.maxTags,n]),m=h=>n(a.filter(b=>b!==h)),g=h=>{h.key==="Enter"||h.key===","?(h.preventDefault(),p(i)):h.key==="Backspace"&&i===""&&a.length>0&&m(a[a.length-1])},f=s||e.disabled;return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("div",{className:["flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px] cursor-text","focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30",f?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!f&&u.current?.focus(),children:[a.map(h=>c("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[h,!f&&t("button",{type:"button",onClick:()=>m(h),className:"hover:text-danger",children:t(Ce,{className:"h-2.5 w-2.5"})})]},h)),t("input",{ref:u,type:"text",className:"flex-1 min-w-[80px] bg-transparent text-sm text-foreground outline-none placeholder:text-foreground-disabled",value:i,placeholder:a.length===0?e.placeholder??"Add tags…":"",disabled:f,list:`tags-suggestions-${e.key}`,onChange:h=>l(h.target.value),onKeyDown:g,onBlur:()=>{i.trim()&&p(i)}}),e.suggestions&&t("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(h=>t("option",{value:h},h))})]})})}function zl({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const{nodes:a}=ur(),i=typeof r=="string"?r:"",l=e.showOffline?a:a.filter(u=>u.isOnline);return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:c("select",{className:"w-full px-3 py-2 text-sm bg-background border border-border rounded-lg text-foreground focus:outline-none focus:border-primary/50 disabled:opacity-50",value:i,onChange:u=>n(u.target.value),disabled:s,children:[t("option",{value:"",children:"Select node…"}),l.map(u=>c("option",{value:u.id,disabled:!u.isOnline,children:[u.shortName,u.isOnline?"":" (offline)"]},u.id))]})})}function Wl({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const{nodes:a}=ur(),i=new Set(Array.isArray(r)?r.map(String):[]),l=e.showOffline?a:a.filter(p=>p.isOnline),u=p=>{const m=new Set(i);m.has(p)?m.delete(p):m.add(p),n([...m])};return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:t("div",{className:"flex flex-wrap gap-1.5",children:l.map(p=>{const m=i.has(p.id);return t("button",{type:"button",onClick:()=>u(p.id),disabled:s||!p.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${m?"border-primary bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:bg-surface-hover"} ${p.isOnline?"":"opacity-50 cursor-not-allowed"}`,children:p.shortName},p.id)})})})}function Ul({field:e,value:r,onChange:n,disabled:s,translationFn:o}){const a=r==null?"#000000":String(r);return c(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:[c("div",{className:"flex items-center gap-2",children:[t("input",{type:"color",className:"h-9 w-9 rounded-md border border-border bg-background cursor-pointer p-0.5 disabled:opacity-50",value:a,disabled:s||e.disabled,onChange:i=>n(i.target.value)}),t("input",{type:"text",className:Ge+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:s||e.disabled,onChange:i=>n(i.target.value)})]}),e.presets&&e.presets.length>0&&t("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>t("button",{type:"button",className:"h-5 w-5 rounded-md border border-border hover:scale-110 transition-transform disabled:opacity-50",style:{backgroundColor:i},disabled:s||e.disabled,title:i,onClick:()=>n(i)},i))})]})}function Hl({field:e,value:r,onChange:n,disabled:s,translationFn:o,onTestField:a,onAction:i,externalProbe:l}){const[u,p]=k("idle"),[m,g]=k(null),f=l?.status??u,h=l?.result??m,b=!!a||!!i,v=D(async()=>{if(b){p("probing"),g(null);try{const C=a?await a(e.key,r):await i("test-probe",e.key,r),S=C&&typeof C=="object"?C:{status:"error",error:"Probe handler returned no result"};g(S),p(S.status==="ok"?"ok":"error")}catch(C){g({status:"error",error:C instanceof Error?C.message:String(C)}),p("error")}}},[a,i,e.key,r,b]),x=f==="probing"?"border-primary/40 bg-primary/10 text-primary":f==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":f==="error"?"border-danger/40 bg-danger/10 text-danger hover:bg-danger/15":"border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover",y=f==="probing"?t(Ee,{className:"h-3 w-3 animate-spin"}):f==="ok"?t(Qo,{className:"h-3 w-3"}):f==="error"?t(bt,{className:"h-3 w-3"}):t(Tn,{className:"h-3 w-3"});return c(ye,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:o,children:[c("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[c("button",{type:"button",onClick:v,title:"Test",disabled:e.disabled||f==="probing"||!b||!r,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${x}`,children:[y,t("span",{className:"hidden @[280px]:inline",children:"Test"})]}),t("input",{type:e.inputType??"url",className:Ge+" flex-1 min-w-0",value:r==null?"":String(r),placeholder:e.placeholder,disabled:s||e.disabled,onChange:C=>{n(C.target.value),u!=="idle"&&(p("idle"),g(null))}})]}),f==="ok"&&h?.labels&&h.labels.length>0&&t("div",{className:"flex flex-wrap gap-1 mt-1.5",children:h.labels.map((C,S)=>t("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:C},S))}),f==="error"&&h?.error&&t("p",{className:"text-xs text-danger mt-1 truncate",title:h.error,children:h.error})]})}function ql({field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a}){const[i,l]=k(e.defaultCollapsed??!1),u=e.style==="accordion",p=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return t("div",{className:p,children:c("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[c("div",{className:["px-3 py-2 flex items-center justify-between",u?"cursor-pointer hover:bg-surface":""].join(" "),onClick:u?()=>l(m=>!m):void 0,children:[t("span",{className:"text-xs font-semibold text-foreground",children:Re(e.label,o)}),u&&t("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&t("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(m=>t(Ct,{field:m,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a},m.key))})]})})}function Vl({field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,onAction:i}){const l=e.tabs[0]?.id??"",[u,p]=k(l),m=e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1";return e.tabs.length===0?null:c("div",{className:m,children:[e.label&&t("div",{className:Nt,children:Re(e.label,o)}),c("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[t("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(g=>{const f=g.id===u;return c("button",{type:"button",role:"tab","aria-selected":f,onClick:()=>p(g.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${f?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[t("span",{children:Re(g.label,o)}),g.badge&&t("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${f?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:g.badge})]},g.id)})}),e.tabs.map(g=>g.id!==u?null:t("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:g.fields.map((f,h)=>{const b="key"in f&&typeof f.key=="string"?f.key:`__${g.id}__${h}`;return t(Ct,{field:f,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,onAction:i},b)})},g.id))]})]})}function Kl({span:e}){return t("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:t("hr",{className:"border-border"})})}var Kr={info:{border:"border-info",bg:"bg-info/5",text:"text-info"},warning:{border:"border-warning",bg:"bg-warning/5",text:"text-warning"},success:{border:"border-success",bg:"bg-success/5",text:"text-success"},danger:{border:"border-danger",bg:"bg-danger/5",text:"text-danger"}};function Zl({field:e}){const r=e.variant??"info",n=Kr[r]??Kr.info;return t("div",{className:"col-span-full",children:c("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${n.border} ${n.bg}`,children:[e.label&&t("p",{className:`text-xs font-semibold mb-0.5 ${n.text}`,children:e.label}),t("p",{className:"text-xs text-foreground-subtle leading-relaxed",children:e.content})]})})}var Zr={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function Yl(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1e3)return`${e}ms`;const r=Math.round(e/1e3);if(r<60)return`${r}s`;const n=Math.floor(r/60),s=r%60;return s===0?`${n}m`:`${n}m ${s}s`}function Jl(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function Xl({kind:e,value:r}){if(r==null||r==="")return t("span",{className:"text-foreground-subtle/60",children:"—"});if(e==="monospace")return t("span",{className:"font-mono text-[11px]",children:String(r)});if(e==="status"){const n=String(r).toLowerCase(),s=Zr[n]??Zr.unknown;return c("span",{className:"inline-flex items-center gap-1.5",children:[t("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${s}`}),t("span",{children:String(r)})]})}return e==="duration"&&typeof r=="number"?t("span",{className:"font-mono text-[11px]",children:Yl(r)}):e==="timestamp"&&typeof r=="number"?t("span",{className:"font-mono text-[11px]",children:Jl(r)}):t("span",{children:String(r)})}function ec({field:e}){const r=e.value??[],n=e.description;return c("div",{className:"col-span-full",children:[e.label&&t("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),n&&t("p",{className:"text-xs text-foreground-subtle mb-2",children:n}),r.length===0?t("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):t("div",{className:"rounded-md border border-border overflow-hidden",children:c("table",{className:"w-full text-xs",children:[t("thead",{className:"bg-surface-subtle border-b border-border",children:t("tr",{children:e.columns.map(s=>t("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:s.width?{width:s.width}:void 0,children:s.label},s.key))})}),t("tbody",{className:"divide-y divide-border",children:r.map((s,o)=>t("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>t("td",{className:"px-3 py-1.5 align-top text-foreground",children:t(Xl,{kind:a.kind,value:s[a.key]})},a.key))},o))})]})})]})}function tc({field:e,disabled:r,onAction:n}){const[s,o]=k(!1),a=ps(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&n){o(!0);try{await n(e.action,e.key)}finally{o(!1)}}},l={default:"border border-border text-foreground hover:bg-surface-hover",primary:"bg-primary text-primary-foreground hover:bg-primary/90",danger:"bg-danger text-white hover:bg-danger/90"};return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,children:t("button",{onClick:i,disabled:r||s,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${l[e.variant??"default"]??l.default}`,children:s?"Processing...":e.buttonLabel})})}function rc({field:e}){const r=yl();return t(ye,{label:e.label,description:e.description,required:e.required,span:e.span,children:t(Tl,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:r??void 0,instanceId:e.key})})}function nc(e,r){if(e==null)return"—";if(typeof e=="boolean")return e?"yes":"no";if(typeof e=="number"){const n=Number.isInteger(e)?String(e):e.toFixed(2);return r?`${n} ${r}`:n}return typeof e=="string"?e:JSON.stringify(e)}function sc({field:e,values:r,onAction:n,translationFn:s}){const o="key"in e?e.key:void 0;if(!o)return null;const a=r[o],i=a!==void 0?a:"default"in e?e.default:void 0,l="unit"in e?e.unit:void 0,u=nc(i,l),p="label"in e?e.label:void 0,m="description"in e?e.description:void 0,g="span"in e?e.span:void 0,f="actions"in e?e.actions??[]:[];return t(ye,{label:p,description:m,span:g,translationFn:s,children:c("div",{className:"flex items-stretch gap-1",children:[t("div",{className:"flex-1 rounded-md border border-border bg-surface-alt px-2.5 py-1.5 text-xs text-foreground font-mono break-all",children:u}),f.length>0&&t("div",{className:"flex items-center gap-1",children:f.map(h=>t(ac,{action:h,fieldKey:o,value:i,onAction:n},h.action))})]})})}function oc({name:e}){const r="h-3.5 w-3.5";switch(e){case"copy":return t(Oe,{className:r});case"refresh-cw":return t(nr,{className:r});case"external-link":return t(An,{className:r});case"trash-2":return t(Ie,{className:r});case"download":return t(Wt,{className:r});case"upload":return t(En,{className:r});default:return t(ir,{className:r})}}function ac({action:e,fieldKey:r,value:n,onAction:s}){const o=ps(),[a,i]=k(!1),l=e.variant==="danger"?"text-danger hover:bg-danger/10 border-danger/30":e.variant==="primary"?"text-primary hover:bg-primary/10 border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border-border";return t("button",{type:"button",onClick:async()=>{if(!(e.confirmMessage&&!await o({title:e.tooltip,message:e.confirmMessage,variant:e.variant==="danger"?"danger":"default"}))){if(e.action==="copy-value"){try{await navigator.clipboard.writeText(typeof n=="string"?n:String(n))}catch{}return}if(s){i(!0);try{await s(e.action,r)}finally{i(!1)}}}},disabled:a,title:e.tooltip,className:`inline-flex items-center justify-center rounded-md border px-2 py-1.5 transition-colors disabled:opacity-50 ${l}`,children:t(oc,{name:e.icon})})}function ic(e){return"multiple"in e&&e.multiple!=null}function lc({field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,externalProbe:i,allFields:l,onAction:u}){const p=e.multiple,m=p.min,g=p.max,f=r[e.key],b=[...Array.isArray(f)?f:f!=null?[f]:[]],v=p.itemDefault!==void 0?p.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;b.length<m;)b.push(v);const x=P=>n(e.key,[...P]),y=(P,M)=>{const A=[...b];A[P]=M,x(A)},C=()=>{b.length>=g||x([...b,v])},S=P=>{b.length<=m||x(b.filter((M,A)=>A!==P))},E=()=>{const{multiple:P,...M}=e;return{...M,...{label:void 0,description:void 0,required:!1}}};return t(ye,{label:e.label,description:e.description,required:m>0?e.required:!1,span:e.span,translationFn:o,children:c("div",{className:"space-y-2",children:[b.map((P,M)=>{const A=p.itemLabel?.replace("${n}",String(M+1));return c("div",{className:"space-y-1",children:[A&&t("div",{className:Nt,children:A}),c("div",{className:"flex items-center gap-2",children:[t("div",{className:"flex-1 min-w-0",children:t(Ct,{field:E(),values:{...r,[e.key]:P},onChange:(R,$)=>y(M,$),disabled:s,translationFn:o,onTestField:a,onAction:u,allFields:l})}),b.length>m&&t("button",{type:"button",onClick:()=>S(M),disabled:s,title:"Remove",className:"flex-shrink-0 inline-flex items-center justify-center rounded-md border border-border p-1.5 text-foreground-subtle hover:text-danger hover:border-danger/50 transition-colors disabled:opacity-40",children:t(Ie,{className:"h-3.5 w-3.5"})})]})]},M)}),c("div",{className:"flex items-center justify-between pt-1",children:[b.length<g?c("button",{type:"button",onClick:C,disabled:s,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40",children:[t(ar,{className:"h-3 w-3"}),p.addLabel??"Add"]}):t("span",{}),c("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[b.length,"/",g]})]})]})})}function cc(e,r,n){if(!("showWhen"in e)||!e.showWhen)return!0;const s=e.showWhen,o=r[s.field],a=n?.find(u=>"key"in u&&u.key===s.field),i=a&&"default"in a?a.default:void 0,l=o!==void 0?o:i;return s.equals!==void 0?l===s.equals:s.notEquals!==void 0?l!==s.notEquals:s.in!==void 0?s.in.includes(l):s.notIn!==void 0?!s.notIn.includes(l):s.includes!==void 0?Array.isArray(l)&&l.includes(s.includes):s.notIncludes!==void 0?!Array.isArray(l)||!l.includes(s.notIncludes):!0}function Ct({field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,externalProbe:i,allFields:l,onAction:u}){if(ic(e))return t(lc,{field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,externalProbe:i,allFields:l,onAction:u});if("readonlyField"in e&&e.readonlyField===!0)return t(sc,{field:e,values:r,onAction:u,translationFn:o});if(!cc(e,r,l))return null;const p=r[e.key],m=p!==void 0?p:"default"in e?e.default:void 0,g=h=>n(e.key,h),f=xl(e.type);switch(e.type){case"text":return t(Ll,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"number":return t(_l,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"boolean":return t(Ol,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"select":return t(Bl,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"multiselect":return t($l,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"password":return t(Ql,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"textarea":return t(Gl,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"slider":return t(jl,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"tags":return t(Fl,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"color":return t(Ul,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"node-select":return t(zl,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"node-multiselect":return t(Wl,{field:e,value:m,onChange:g,disabled:s,translationFn:o});case"probe":return t(Hl,{field:e,value:m,onChange:g,disabled:s,translationFn:o,onTestField:a,onAction:u,externalProbe:i});case"group":return t(ql,{field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a});case"sub-tabs":return t(Vl,{field:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,onAction:u});case"separator":return t(Kl,{});case"info":return t(Zl,{field:e});case"object-array":return t(ec,{field:e});case"button":return t(tc,{field:e,disabled:s,onAction:u});case"widget":return t(rc,{field:e});default:return f?t(f,{field:e,value:m,onChange:g,disabled:s}):null}}function dc(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Re(e,r){if(e!==void 0)return r&&dc(e)?r(e):e}function uc({section:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,probeResults:i}){const[l,u]=k(e.defaultCollapsed??!1),p=e.style==="accordion",m=e.columns??2,g=m===1?"grid-cols-1":m===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":m===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return c("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[c("div",{className:["flex items-center justify-between mb-2",p?"cursor-pointer":""].join(" "),onClick:p?()=>u(f=>!f):void 0,children:[c("div",{children:[t("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:Re(e.title,o)}),e.description&&t("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:Re(e.description,o)})]}),p&&t("span",{className:"text-foreground-subtle text-xs ml-2",children:l?"▸":"▾"})]}),!l&&t("div",{className:`grid ${g} gap-x-3 gap-y-2.5`,children:e.fields.map(f=>t(Ct,{field:f,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,externalProbe:i?.[f.key]},f.key))})]})}function pc({schema:e,values:r,onChange:n,disabled:s,translationFn:o,onTestField:a,probeResults:i,onClearProbe:l}){const u=(p,m)=>{n({...r,[p]:m}),l?.(p)};return t("div",{className:"space-y-4",children:e.sections.map(p=>t(uc,{section:p,values:r,onChange:u,disabled:s,translationFn:o,onTestField:a,probeResults:i},p.id))})}var mc=({open:e})=>t("svg",{className:`h-3 w-3 transition-transform ${e?"rotate-90":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:t("polyline",{points:"9 18 15 12 9 6"})});function Yr(e){const r={};if(!e)return r;for(const n of e.sections)for(const s of n.fields){if(s.type==="separator"||s.type==="info"||s.type==="button"||s.type==="group")continue;const o=s.key;r[o]=s.value}return r}function gc(e){return{...e,sections:e.sections.map(r=>({...r,fields:r.fields.map(n=>{if(n.type==="separator"||n.type==="info"||n.type==="button"||n.type==="group")return n;const{value:s,...o}=n;return o})}))}}function jx({trpc:e,addonId:r,nodeId:n,title:s,disabled:o,onAfterChange:a,refreshToken:i,collapsible:l,defaultOpen:u,mode:p,onOverrideChange:m}){const g=p??"persist",[f,h]=k(null),[b,v]=k(!0),[x,y]=k(null),[C,S]=k(!1),[E,P]=k(u??!1),[M,A]=k({}),[R,$]=k(null);G(()=>{$(null),A({})},[e,r,n,i,g]);const q=JSON.stringify(M);G(()=>{let te=!1;v(!0),y(null);const X=g==="override"&&Object.keys(M).length>0?M:void 0;return e.addonSettings.getGlobalSettings.query({addonId:r,nodeId:n,...X?{overlay:X}:{}}).then(Z=>{te||(h(Z),X||$(Yr(Z)),v(!1))}).catch(Z=>{te||(y(Z instanceof Error?Z.message:String(Z)),v(!1))}),()=>{te=!0}},[e,r,n,i,g,q]);const V=U(()=>Yr(f),[f]),he=U(()=>f?gc(f):null,[f]),ee=async te=>{if(g==="override"){const Z=R??V,ae={};for(const L of Object.keys(te))te[L]!==Z[L]&&(ae[L]=te[L]);const pe={...Z,...ae};A(ae),m?.(ae,pe);return}const X={};for(const Z of Object.keys(te))te[Z]!==V[Z]&&(X[Z]=te[Z]);if(Object.keys(X).length!==0){S(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:r,nodeId:n,patch:X});const Z=await e.addonSettings.getGlobalSettings.query({addonId:r,nodeId:n});h(Z),a?.()}catch(Z){y(Z instanceof Error?Z.message:String(Z))}finally{S(!1)}}};if(b)return c("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",s??r,"…"]});if(x)return c("div",{className:"text-xs text-red-400",children:[s??r,": ",x]});if(!f||!he)return c("div",{className:"text-xs text-foreground-subtle",children:[s??r," not available on ",n,"."]});const ie=g==="override"?{...V,...M}:V,fe=c(ge,{children:[g==="override"?t("div",{className:"mb-2 text-[11px] text-foreground-subtle",children:"Benchmark override — applies to this run only. The addon's saved settings are not changed."}):null,t(pc,{schema:he,values:ie,onChange:ee,disabled:o===!0||C})]});return l===!0?c("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[c("button",{type:"button",onClick:()=>P(te=>!te),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":E,children:[t(mc,{open:E}),t("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:s??r}),t("span",{className:"text-[10px] text-foreground-subtle",children:E?"hide":"edit"})]}),E?t("div",{className:"border-t border-border px-4 py-3",children:fe}):null]}):s?c("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[t("div",{className:"border-b border-border px-4 py-2",children:t("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:s})}),t("div",{className:"px-4 py-3",children:fe})]}):t("div",{children:fe})}function fc({detections:{motion:e,motionRaw:r,detection:n,phase:s},showMotionZones:o=!0,showMotionRaw:a=!0,showDetections:i=!0,showPhaseIndicator:l=!0}){const u=o&&e&&e.zones.length>0,p=a&&r&&r.boxes.length>0,m=i&&n&&n.detections.length>0;return!u&&!p&&!m&&!l?null:c("div",{className:"absolute inset-0 pointer-events-none z-10",children:[l&&t(hc,{phase:s}),p&&t(bc,{raw:r}),u&&t(vc,{motion:e}),m&&t(xc,{detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function hc({phase:e}){const r=Fn(e);return c("div",{className:"absolute top-2 left-2 flex items-center gap-1.5 px-2 py-1 rounded-md bg-black/60 backdrop-blur-sm",children:[t("span",{className:`w-2 h-2 rounded-full ${r.dotClass}`}),t("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:r.label})]})}function bc({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:t(ge,{children:e.boxes.map((r,n)=>{const[s,o,a,i]=r.bbox,l=s/e.frameWidth*100,u=o/e.frameHeight*100,p=(a-s)/e.frameWidth*100,m=(i-o)/e.frameHeight*100,g=Math.max(.05,Math.min(.25,r.changeScore*.3));return t("div",{className:"absolute rounded-sm",style:{left:`${l}%`,top:`${u}%`,width:`${p}%`,height:`${m}%`,backgroundColor:`rgba(239, 68, 68, ${g})`}},`mr-${n}`)})})}function vc({motion:e}){if(e.frameWidth===0||e.frameHeight===0)return null;const r=e.zones.filter(n=>n.w*n.h/(e.frameWidth*e.frameHeight)<.9);return t(ge,{children:r.map((n,s)=>{const o=Math.max(.15,Math.min(.5,n.intensity/255));return t("div",{className:"absolute rounded-sm",style:{left:`${n.x/e.frameWidth*100}%`,top:`${n.y/e.frameHeight*100}%`,width:`${n.w/e.frameWidth*100}%`,height:`${n.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${o})`,backgroundColor:`rgba(250, 204, 21, ${o*.15})`}},`mz-${s}`)})})}function xc({detections:e,frameWidth:r,frameHeight:n}){return r===0||n===0?null:t(ge,{children:e.map(s=>{const{x:o,y:a,width:i,height:l}=s.bbox,u=o/r*100,p=a/n*100,m=i/r*100,g=l/n*100,f=Me(s.macroClass),h=[`${s.macroClass} ${(s.score*100).toFixed(0)}%`];for(const b of s.labels)h.push(b.label);return t("div",{className:"absolute border-2 rounded-sm",style:{left:`${u}%`,top:`${p}%`,width:`${m}%`,height:`${g}%`,borderColor:f},children:t("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:f},children:h.join(" | ")})},`det-${s.id}`)})})}function yc(e){const r={};if(typeof window<"u"){if(e){const s=e.getBoundingClientRect();s.width>0&&s.height>0&&(r.viewportWidth=Math.round(s.width),r.viewportHeight=Math.round(s.height))}r.viewportWidth===void 0&&(r.viewportWidth=window.innerWidth,r.viewportHeight=window.innerHeight),r.devicePixelRatio=window.devicePixelRatio||1;const n=navigator.connection;n?.downlink&&n.downlink>0&&(r.downlinkMbps=n.downlink)}return r}var wc=3e3,Nc=5;function Cc({serverUrl:e,streamKey:r,label:n,autoPlay:s=!0,muted:o=!0,showControls:a=!0,className:i="",onStateChange:l,onError:u,overlay:p,createSession:m,sendAnswer:g,closeSession:f,hintsOverride:h}){const b=z(null),v=z(null),x=z(null),y=z(new Set),C=z(null),S=z(null),E=z(0),P=z(!0),[M,A]=k("idle"),[R,$]=k(""),[q,V]=k(o),[he,ee]=k(!1),[ie,fe]=k(!1),te=z(null),X=z(!1);(g||m)&&(X.current=!0);const Z=X.current,ae=D(H=>{A(H),l?.(H)},[l]),pe=D(()=>{if(C.current?.abort(),C.current=null,S.current&&(clearTimeout(S.current),S.current=null),x.current&&(x.current.close(),x.current=null),f&&y.current.size>0){for(const H of y.current)f(H).catch(()=>{});y.current.clear()}b.current&&(b.current.srcObject=null)},[f]),L=D(async()=>{if(!P.current||!m||!g)return;pe(),ae("connecting");const H=new AbortController;C.current=H;try{const be={...yc(v.current),...h},{sessionId:xe,sdpOffer:Ne}=await m(be);if(y.current.add(xe),!P.current||H.signal.aborted){f?.(xe).catch(()=>{}),y.current.delete(xe);return}const N=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=N;const T=new MediaStream;N.ontrack=Q=>{console.debug("[WebRTC] ontrack",Q.track.kind,Q.track.readyState),T.addTrack(Q.track),b.current&&(b.current.srcObject=T,b.current.play().catch(()=>{}))},N.oniceconnectionstatechange=()=>{if(!P.current)return;const Q=N.iceConnectionState;console.debug("[WebRTC] ICE state:",Q),Q==="connected"||Q==="completed"?(E.current=0,ae("playing"),b.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),b.current.play().catch(()=>{}))):(Q==="failed"||Q==="disconnected"||Q==="closed")&&(ae("disconnected"),re())},N.onicecandidateerror=Q=>{console.debug("[WebRTC] ICE candidate error:",Q)},console.debug("[WebRTC] Setting remote description (server offer)..."),await N.setRemoteDescription({type:"offer",sdp:Ne});const O=await N.createAnswer();if(await N.setLocalDescription(O),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await Jr(N),!P.current)return;const K=(N.localDescription?.sdp??"").split(`
|
|
31
|
-
`).filter(Q=>Q.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:K,sessionId:xe.slice(0,8)}),await g(xe,N.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const B=N,le=()=>{const Q=B.connectionState;if(Q==="closed"||Q==="failed")return;const ue=b.current;ue&&ue.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${B.iceConnectionState})`)};setTimeout(le,3e3),setTimeout(le,8e3)}catch(me){if(!P.current)return;const be=me instanceof Error?me.message:String(me);$(be),ae("error"),u?.(be),re()}},[e,r,m,g,pe,ae,u,h]),_=D(async()=>{if(P.current){pe(),ae("connecting");try{const H=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});x.current=H,H.addTransceiver("video",{direction:"recvonly"}),H.addTransceiver("audio",{direction:"recvonly"});const me=new MediaStream;H.ontrack=T=>{me.addTrack(T.track),b.current&&(b.current.srcObject=me,b.current.play().catch(()=>{}))},H.oniceconnectionstatechange=()=>{if(!P.current)return;const T=H.iceConnectionState;T==="connected"||T==="completed"?(E.current=0,ae("playing"),b.current?.paused&&b.current.play().catch(()=>{})):(T==="failed"||T==="disconnected"||T==="closed")&&(ae("disconnected"),re())};const be=await H.createOffer();if(await H.setLocalDescription(be),await Jr(H),!P.current)return;const xe=`${e}/api/webrtc?src=${encodeURIComponent(r)}`,Ne=await fetch(xe,{method:"POST",headers:{"Content-Type":"application/sdp"},body:H.localDescription?.sdp??""});if(!Ne.ok)throw new Error(`WHEP ${Ne.status}: ${Ne.statusText}`);const N=await Ne.text();await H.setRemoteDescription({type:"answer",sdp:N})}catch(H){if(!P.current)return;const me=H instanceof Error?H.message:String(H);$(me),ae("error"),u?.(me),re()}}},[e,r,pe,ae,u]),J=Z?L:_,W=z(()=>{});W.current=J;const re=D(()=>{P.current&&(E.current>=Nc||(E.current+=1,S.current=setTimeout(()=>{P.current&&W.current()},wc)))},[]);G(()=>(P.current=!0,E.current=0,s&&J(),()=>{P.current=!1,pe()}),[e,r]);const ne=z(!1);G(()=>{!s||!Z||!m||!g||ne.current||x.current||(ne.current=!0,J())},[s,Z,m,g,J]);const j=()=>{E.current=0,J()},Y=()=>{b.current&&(b.current.muted=!b.current.muted,V(b.current.muted))},se=async()=>{if(v.current)try{document.fullscreenElement?await document.exitFullscreen():await v.current.requestFullscreen()}catch(H){console.warn(`Fullscreen toggle failed: ${H instanceof Error?H.message:H}`)}},ve=()=>{if(!b.current)return;const H=document.createElement("canvas");H.width=b.current.videoWidth||1280,H.height=b.current.videoHeight||720;const me=H.getContext("2d");if(!me)return;me.drawImage(b.current,0,0);const be=document.createElement("a");be.download=`${r.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,be.href=H.toDataURL("image/jpeg",.92),be.click()};G(()=>{const H=()=>ee(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",H),()=>document.removeEventListener("fullscreenchange",H)},[]);const Pe=()=>{fe(!0),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>fe(!1),3e3)};return c("div",{ref:v,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:Pe,onMouseEnter:Pe,children:[t("video",{ref:b,autoPlay:s,muted:q,playsInline:!0,className:"w-full h-full object-contain"}),n&&M==="playing"&&t("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:n}),p,M==="connecting"&&c("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[t("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:t("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"32",strokeDashoffset:"32",className:"animate-[dash_1.5s_ease-in-out_infinite]"})}),t("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(M==="error"||M==="disconnected")&&c("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[t("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t("path",{d:"M1 1l5.5 5.5M23 23l-5.5-5.5M8.11 15.89a8 8 0 0110.78-10.78M3.64 3.64A12 12 0 0020.36 20.36",strokeLinecap:"round"})}),t("span",{className:"text-xs text-red-400 text-center px-4",children:M==="error"?R||"Connection failed":"Disconnected"}),t("button",{onClick:j,className:"mt-1 inline-flex items-center gap-1.5 rounded px-3 py-1 text-xs bg-white/10 text-white hover:bg-white/20 transition-colors",children:"Reconnect"})]}),a&&M==="playing"&&c("div",{className:`absolute bottom-0 inset-x-0 flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${ie?"opacity-100":"opacity-0"}`,children:[t("div",{className:"flex items-center gap-1",children:t(_t,{onClick:Y,title:q?"Unmute":"Mute",children:q?c("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),t("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),t("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):c("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),t("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),c("div",{className:"flex items-center gap-1",children:[t(_t,{onClick:ve,title:"Take snapshot",children:c("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[t("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),t("circle",{cx:"12",cy:"13",r:"4"})]})}),t(_t,{onClick:se,title:he?"Exit fullscreen":"Fullscreen",children:he?t("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})}):t("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 3H5a2 2 0 00-2 2v3m18 0V5a2 2 0 00-2-2h-3m0 18h3a2 2 0 002-2v-3M3 16v3a2 2 0 002 2h3"})})})]})]})]})}function _t({onClick:e,title:r,children:n}){return t("button",{onClick:e,title:r,className:"rounded-full p-1.5 text-white/80 hover:text-white hover:bg-white/20 transition-colors",children:n})}async function Jr(e){if(e.iceGatheringState!=="complete")return new Promise(r=>{const n=()=>{e.iceGatheringState==="complete"&&(e.removeEventListener("icegatheringstatechange",n),r())};e.addEventListener("icegatheringstatechange",n),setTimeout(r,5e3)})}var gr=Be("camstack:player-overlays-state",null),fr=Be("camstack:player-overlays-actions",null);function Fx({children:e}){const[r,n]=k(()=>new Map),[s,o]=k(()=>new Map),a=D(g=>{n(f=>{const h=new Map(f);return h.set(g.id,g),h})},[]),i=D(g=>{n(f=>{if(!f.has(g))return f;const h=new Map(f);return h.delete(g),h})},[]),l=D(g=>{o(f=>{const h=new Map(f);return h.set(g.id,g),h})},[]),u=D(g=>{o(f=>{if(!f.has(g))return f;const h=new Map(f);return h.delete(g),h})},[]),p=U(()=>({layers:r,buttons:s}),[r,s]),m=U(()=>({setLayer:a,removeLayer:i,setButton:l,removeButton:u}),[a,i,l,u]);return t(gr.Provider,{value:p,children:t(fr.Provider,{value:m,children:e})})}function zx(){const e=we(gr);return U(()=>e?[...e.layers.values()].sort((r,n)=>r.order-n.order):[],[e])}function Sc(){const e=we(gr);return U(()=>e?[...e.buttons.values()].sort((r,n)=>r.order-n.order):[],[e])}function Wx(e){const r=we(fr);G(()=>{if(!(!r||!e))return r.setLayer(e),()=>r.removeLayer(e.id)},[r,e])}function Ux(e){const r=we(fr);G(()=>{if(!(!r||!e))return r.setButton(e),()=>r.removeButton(e.id)},[r,e])}function kc(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function Mc(e){const r=Math.floor(e/1e3);return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:`${Math.floor(r/3600)}h${Math.floor(r%3600/60)}m`}function Jt({className:e}){return t("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t("polygon",{points:"5 3 19 12 5 21 5 3"})})}function Pc({className:e}){return t("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function Ac({className:e}){return c("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),t("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),t("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),t("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function Dc({className:e}){return c("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[t("circle",{cx:"5",cy:"12",r:"2"}),t("circle",{cx:"12",cy:"12",r:"2"}),t("circle",{cx:"19",cy:"12",r:"2"})]})}function Ot({label:e,active:r,onClick:n}){return c("button",{type:"button",onClick:n,className:"w-full flex items-center justify-between gap-3 px-3 py-1.5 text-[11px] text-foreground hover:bg-surface-hover transition-colors",children:[t("span",{children:e}),t("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${r?"bg-primary":"bg-foreground-subtle/30"} relative`,children:t("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${r?"left-2.5":"left-0.5"}`})})]})}function Ds({className:e}){return c("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t("polyline",{points:"23 4 23 10 17 10"}),t("polyline",{points:"1 20 1 14 7 14"}),t("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function Ec({className:e}){return c("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),t("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),t("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),t("path",{d:"M18 12l-1.5-1.5"}),t("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),t("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function Hx({serverUrl:e,createSession:r,sendAnswer:n,closeSession:s,streams:o,activeStreamId:a,onStreamChange:i,deviceName:l,phase:u,pipelineMetrics:p,detections:m,defaultShowDetections:g=!0,defaultShowMotion:f=!1,streamStats:h,autoPlay:b=!1,showPlayStop:v=!1,snapshotSrc:x,snapshotLoading:y=!1,onRefreshSnapshot:C,showStreamStats:S=!1,children:E,extraOverlay:P,ptzAvailable:M=!1,ptzShown:A=!1,ptzOverlay:R,onPtzToggle:$,intercomAvailable:q=!1,intercomShown:V=!1,onIntercomToggle:he,chromeless:ee=!1,className:ie}){const fe=Sc(),[te,X]=k(b),[Z,ae]=k(g),[pe,L]=k(f),[_,J]=k(null),[W,re]=k(!1),ne=z(null);G(()=>{if(!W)return;function B(le){ne.current&&!ne.current.contains(le.target)&&re(!1)}return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[W]);const j=a??_??o?.[0]?.id??"",Y=o?.find(B=>B.id===j)??o?.[0],se=Y?.inputFps!=null?{status:Y.status??"unknown",inputFps:Y.inputFps,bitrateKbps:Y.bitrateKbps??0}:null,ve=B=>{J(B),i?.(B),te&&v&&(X(!1),setTimeout(()=>X(!0),50))},Pe=U(()=>{const B=Y?.target;if(B)return le=>r(B,le)},[r,Y]),H=o,me=()=>X(!0),be=()=>X(!1),xe=p?.phase??u,Ne=xe==="active",N=!!m,T=N&&(Z||pe),O=M&&A&&!!R,K=v?te:!0;return c("div",{className:`overflow-hidden ${ee?"":"rounded-xl border border-border bg-surface"} ${ie??""}`,children:[c("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[c("div",{className:"flex items-center gap-2",children:[(h??se)&&t("span",{className:`w-2 h-2 rounded-full ${kc((h??se).status)}`}),l&&t("span",{className:"text-xs font-medium text-foreground",children:l}),H&&H.length>1&&c("div",{className:"relative",children:[t("select",{"data-testid":"stream-profile-select",value:j,onChange:B=>ve(B.target.value),className:"appearance-none cursor-pointer rounded-md border border-border bg-surface-hover hover:bg-surface text-foreground text-[11px] font-medium pl-2 pr-6 py-1 focus:outline-none focus:ring-1 focus:ring-primary transition-colors",children:H.map(B=>t("option",{value:B.id,children:B.label},B.id))}),t("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:t("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),c("div",{className:"flex items-center gap-1.5",children:[q&&c("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":V?"true":"false",onClick:he,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${V?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:V?"Close intercom":"Open intercom",children:[t(Ac,{className:"h-3 w-3"}),t("span",{className:"hidden xl:inline",children:"Intercom"})]}),fe.map(B=>{const Q=B.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return c("button",{type:"button","data-toolbar-button-id":B.id,"data-toolbar-button-active":B.active?"true":"false",onClick:B.onClick,disabled:B.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${B.active?Q:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:B.title??B.label,children:[B.icon,t("span",{className:"hidden xl:inline",children:B.label})]},B.id)}),v&&c("button",{"data-testid":"stream-play-toggle","data-stream-playing":K?"true":"false",onClick:K?be:me,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${K?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:K?"Stop stream":"Start stream",children:[K?t(Pc,{className:"h-3 w-3"}):t(Jt,{className:"h-3 w-3"}),t("span",{className:"hidden xl:inline",children:K?"Stop":"Play"})]}),C&&c("button",{"data-testid":"stream-snapshot-refresh",onClick:C,disabled:y,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50",title:"Force snapshot refresh",children:[t(Ds,{className:`h-3 w-3 ${y?"animate-spin":""}`}),t("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(N||M||p||xe||h||se&&se.inputFps>0)&&c("div",{ref:ne,className:"relative",children:[t("button",{onClick:()=>re(B=>!B),title:"More controls",className:"inline-flex items-center justify-center rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",children:t(Dc,{className:"h-3.5 w-3.5"})}),W&&c("div",{className:"absolute right-0 top-full mt-1 z-30 min-w-[200px] rounded-lg border border-border bg-surface shadow-xl py-1.5",children:[S&&h&&c("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Input"}),c("span",{className:"tabular-nums text-foreground",children:[h.inputFps.toFixed(1)," fps"]})]}),c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Decode"}),c("span",{className:"tabular-nums text-foreground",children:[h.decodeFps.toFixed(1)," fps"]})]}),c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Uptime"}),t("span",{className:"tabular-nums text-foreground",children:Mc(h.uptimeMs)})]})]}),!S&&se&&se.inputFps>0&&c("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Input"}),c("span",{className:"tabular-nums text-foreground",children:[se.inputFps.toFixed(1)," fps"]})]}),se.bitrateKbps>0&&c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Bitrate"}),c("span",{className:"tabular-nums text-foreground",children:[se.bitrateKbps," kbps"]})]})]}),(p||N&&xe)&&c("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[c("div",{className:"flex justify-between gap-3 items-center",children:[t("span",{children:"Phase"}),c("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${Ne?"text-red-400":"text-emerald-400"}`,children:[t("span",{className:`w-1.5 h-1.5 rounded-full ${Ne?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),Ne?"Active":"Watching"]})]}),p&&p.detectionFps>0&&c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Detection"}),c("span",{className:"tabular-nums text-foreground",children:[p.detectionFps.toFixed(1)," det/s"]})]}),p&&p.avgInferenceMs>0&&c("div",{className:"flex justify-between gap-3",children:[t("span",{children:"Inference"}),c("span",{className:"tabular-nums text-foreground",children:[p.avgInferenceMs.toFixed(0)," ms"]})]})]}),N&&c(ge,{children:[t(Ot,{label:"Show detections",active:Z,onClick:()=>ae(B=>!B)}),t(Ot,{label:"Show motion",active:pe,onClick:()=>L(B=>!B)})]}),M&&t(Ot,{label:"PTZ controls",active:A,onClick:()=>{$?.(),re(!1)}})]})]})]})]}),K?t("div",{className:"aspect-video relative",children:t(Cc,{serverUrl:e,streamKey:j,autoPlay:!0,className:"w-full h-full",createSession:Pe,sendAnswer:n,closeSession:s,overlay:T||P||O?c(ge,{children:[T&&t(fc,{detections:m,showPhaseIndicator:!1,showMotionZones:pe,showMotionRaw:pe,showDetections:Z}),P,O&&R]}):void 0},j)}):t(Tc,{src:x??null,isLoading:y,onPlay:me,onRetry:C,extraOverlay:P||O?c(ge,{children:[P,O&&R]}):null,suppressPlayHover:!!P||O}),E]})}function Tc({src:e,isLoading:r,onPlay:n,onRetry:s,extraOverlay:o,suppressPlayHover:a=!1}){return e?c("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[t("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&t("button",{onClick:n,className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity cursor-pointer",children:t("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:t(Jt,{className:"h-7 w-7 text-white ml-0.5"})})}),o]}):r?t("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:t("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):t("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:c("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[t(Ec,{className:"h-8 w-8"}),t("span",{className:"text-xs",children:"No snapshot available"}),c("div",{className:"flex items-center gap-2 mt-1",children:[s&&c("button",{onClick:s,className:"inline-flex items-center gap-1.5 rounded-md border border-white/20 px-3 py-1.5 text-xs font-medium text-white/60 hover:text-white hover:border-white/40 transition-colors",children:[t(Ds,{className:"h-3 w-3"}),"Retry"]}),c("button",{onClick:n,className:"inline-flex items-center gap-1.5 rounded-md bg-primary/80 px-3 py-1.5 text-xs font-medium text-white hover:bg-primary transition-colors",children:[t(Jt,{className:"h-3 w-3"}),"Play Live"]})]})]})})}function qx({samples:e,sampleRate:r=16e3,height:n=96,className:s="",color:o="#3b82f6",bgColor:a="transparent"}){const i=z(null),l=z(null),u=D(()=>{const g=i.current,f=l.current;if(!g||!f||!e||e.length===0)return;const h=f.clientWidth;if(h===0)return;const b=window.devicePixelRatio||1;g.width=h*b,g.height=n*b,g.style.width=`${h}px`,g.style.height=`${n}px`;const v=g.getContext("2d");if(!v)return;v.scale(b,b),a!=="transparent"?(v.fillStyle=a,v.fillRect(0,0,h,n)):v.clearRect(0,0,h,n);const x=e.length/h,y=n/2;v.fillStyle=o,v.globalAlpha=.7;for(let C=0;C<h;C++){const S=Math.floor(C*x),E=Math.min(Math.floor((C+1)*x),e.length);let P=0,M=0;for(let q=S;q<E;q++){const V=e[q];V<P&&(P=V),V>M&&(M=V)}const A=y-M*y,R=y-P*y,$=Math.max(1,R-A);v.fillRect(C,A,1,$)}v.globalAlpha=1,v.strokeStyle=o,v.globalAlpha=.2,v.lineWidth=1,v.beginPath(),v.moveTo(0,y),v.lineTo(h,y),v.stroke(),v.globalAlpha=1},[e,n,o,a]);G(()=>{u()},[u]),G(()=>{const g=new ResizeObserver(()=>u()),f=l.current;return f&&g.observe(f),()=>g.disconnect()},[u]);const m=((e&&r?Math.round(e.length/r*1e3):0)/1e3).toFixed(1);return c("div",{ref:l,className:`relative ${s}`,children:[t("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&c("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[m,"s · ",r/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function Vx({currentDbfs:e,durationSec:r=30,maxSamples:n=120,height:s=64,className:o="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:l=-6,minDbfs:u=-96}){const p=z(null),m=z(null),[g,f]=k([]);G(()=>{e!==null&&f(v=>{const x=[...v,{dbfs:e,timestamp:Date.now()}];return x.length>n?x.slice(-n):x})},[e,n]);const h=D(()=>{const v=p.current,x=m.current;if(!v||!x)return;const y=x.clientWidth;if(y===0)return;const C=window.devicePixelRatio||1;v.width=y*C,v.height=s*C,v.style.width=`${y}px`,v.style.height=`${s}px`;const S=v.getContext("2d");if(!S||(S.scale(C,C),S.clearRect(0,0,y,s),g.length===0))return;const E=g[g.length-1].timestamp,P=r*1e3,M=E-P,A=g.filter(V=>V.timestamp>=M);if(A.length===0)return;const R=Math.max(1,Math.floor(y/(r*2))),$=Math.abs(u);for(const V of A){const he=V.timestamp-M,ee=Math.floor(he/P*y),fe=(Math.max(u,Math.min(0,V.dbfs))-u)/$,te=Math.max(1,fe*s),X=V.dbfs>=l;S.fillStyle=X?i:a,S.globalAlpha=.8,S.fillRect(ee,s-te,R,te)}S.globalAlpha=1;const q=s-(l-u)/$*s;S.strokeStyle=i,S.globalAlpha=.25,S.lineWidth=1,S.setLineDash([4,4]),S.beginPath(),S.moveTo(0,q),S.lineTo(y,q),S.stroke(),S.setLineDash([]),S.globalAlpha=1},[g,r,s,a,i,l,u]);G(()=>{h()},[h]),G(()=>{const v=new ResizeObserver(()=>h()),x=m.current;return x&&v.observe(x),()=>v.disconnect()},[h]);const b=g.length>0?g[g.length-1].dbfs:null;return c("div",{ref:m,className:`relative ${o}`,children:[t("canvas",{ref:p,className:"w-full rounded-md"}),c("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[r,"s"]}),b!==null&&c("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[b.toFixed(1)," dBFS · ",g.length," samples"]})]})}function Ic(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function Rc(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function Kx({classifications:e,processing:r=!1,inferenceMs:n,maxItems:s=10,className:o=""}){const a=e.slice(0,s),i=a.length>0?a[0].score:1;return r?t("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${o}`,children:t("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?t("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${o}`,children:t("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):c("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${o}`,children:[c("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[t("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),c("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&c("span",{children:["showing ",a.length," of ",e.length]}),n!==void 0&&c("span",{className:"font-mono",children:[n.toFixed(1),"ms"]})]})]}),t("div",{className:"divide-y divide-border/50",children:a.map((l,u)=>{const p=i>0?l.score/i*100:0;return c("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[t("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:u+1}),t("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:l.className}),t("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:t("div",{className:`h-full rounded-full transition-all duration-300 ${Ic(l.score)}`,style:{width:`${p}%`}})}),c("span",{className:`text-xs font-mono font-semibold w-14 text-right ${Rc(l.score)}`,children:[(l.score*100).toFixed(1),"%"]})]},`${l.className}-${u}`)})})]})}function Zx({data:e,label:r="Response",className:n=""}){const[s,o]=k(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return c("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[c("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between cursor-pointer select-none hover:bg-surface-hover/30",onClick:()=>o(i=>!i),children:[c("div",{className:"flex items-center gap-2",children:[t("span",{className:"text-[10px] text-foreground-subtle",children:s?"▼":"▶"}),t("h3",{className:"text-xs font-medium text-foreground",children:r})]}),t("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),s&&t("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:t("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}var Lc={Activity:_e,Eye:xt,AlertTriangle:Xe,PauseCircle:wo,PowerOff:yo};function Yx({phase:e,...r}){const n=Fn(e),s=Lc[n.icon];return t(s,{...r})}function We(e){const[r,n]=k([]),s=D(a=>{n(i=>{const l=[...i,a];return l.length>e?l.slice(-e):l})},[e]),o=D(()=>{n([])},[]);return U(()=>({entries:r,append:s,reset:o}),[r,s,o])}function Xr(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var en={error:{icon:bt,color:"text-red-400"},warn:{icon:Xe,color:"text-amber-400"},info:{icon:go,color:"text-blue-400"},debug:{icon:mo,color:"text-gray-500"}},tn={debug:0,info:1,warn:2,error:3},_c=["all","debug","info","warn","error"],Oc=500;function Bc(e,r){return r?(tn[e]??0)>=(tn[r]??0):!0}function Es({agentId:e,addonId:r,deviceId:n,integrationId:s,requestId:o,level:a,maxHeight:i="max-h-96",showScope:l=!1,showFilters:u=!0,limit:p=100,liveBuffer:m,onClose:g,className:f}){const[h,b]=k(""),[v,x]=k(""),[y,C]=k(a),S=e,E=r??(h||void 0),P=n??(v?Number(v):void 0),M=s,A=o,R=U(()=>{const N={};return S&&(N.agentId=S),E&&(N.addonId=E),P!==void 0&&Number.isFinite(P)&&(N.deviceId=P),M&&(N.integrationId=M),A&&(N.requestId=A),Object.keys(N).length>0?N:void 0},[S,E,P,M,A]),$=We(Oc),q=m??$,V=q.entries,[he,ee]=k(0),[ie,fe]=k(!1),[te,X]=k(!1),[Z,ae]=k(new Set),[pe,L]=k(""),_=z(null),J=`${S??""}:${E??""}:${String(P??"")}:${M??""}:${A??""}`,W=z(J);G(()=>{W.current!==J&&(W.current=J,q.reset(),ee(0),ae(new Set))},[J,q]);const{data:re,isLoading:ne}=d.logs.query.useQuery({...R?{tags:R}:{},limit:p},{staleTime:3e4});d.logs.subscribe.useSubscription({...R?{tags:R}:{}},{onData:N=>{q.append(N)}});const j=z(V.length);G(()=>{const N=_.current;if(!N){j.current=V.length;return}const T=j.current;if(j.current=V.length,!(V.length<=T)){if(ie&&N.scrollTop<=8)N.scrollTo({top:0});else if(!ie&&N.scrollTop>0){const O=N.querySelector("tbody tr"),K=O instanceof HTMLElement?O.offsetHeight:24;N.scrollTop+=K*(V.length-T)}}},[V.length,ie]);const Y=U(()=>{const N=(re??[]).map(Q=>({timestamp:Q.timestamp,level:Q.level,message:Q.message,scope:Q.scope,tags:Q.tags,meta:Q.meta})),T=new Set,O=[];for(const Q of[...V].reverse()){const ue=`${Q.timestamp}|${Q.level}|${Q.scope??""}|${Q.message}`;T.has(ue)||(T.add(ue),O.push(Q))}for(const Q of N){const ue=`${Q.timestamp}|${Q.level}|${Q.scope??""}|${Q.message}`;T.has(ue)||(T.add(ue),O.push(Q))}const B=(he>0?O.filter(Q=>new Date(Q.timestamp).getTime()>he):O).filter(Q=>Bc(Q.level,y)),le=pe.trim().toLowerCase();return le?B.filter(Q=>{if(Q.message.toLowerCase().includes(le)||Q.scope&&Q.scope.toLowerCase().includes(le))return!0;if(Q.tags){for(const ue of Object.values(Q.tags))if(ue!==void 0&&String(ue).toLowerCase().includes(le))return!0}if(Q.meta){for(const ue of Object.values(Q.meta))if(ue!=null&&Xr(ue).toLowerCase().includes(le))return!0}return!1}):B},[re,V,y,he,pe]),se=D(()=>{const N=Y.map(T=>{const O=new Date(T.timestamp).toLocaleTimeString(),K=T.tags?" "+Object.entries(T.tags).filter(([,B])=>B).map(([B,le])=>`${B}=${le}`).join(" "):"";return`${O} [${T.level.toUpperCase()}]${T.scope?` [${T.scope}]`:""}${K} ${T.message}`});navigator.clipboard.writeText(N.join(`
|
|
32
|
-
`)).then(()=>{X(!0),setTimeout(()=>X(!1),1500)})},[Y]),ve=d.logs.clear.useMutation(),Pe=D(()=>{ee(Date.now()),q.reset(),ve.mutate({...R?{tags:R}:{}})},[q,ve,R]),H=D(N=>{ae(T=>{const O=new Set(T);return O.has(N)?O.delete(N):O.add(N),O})},[]),[me,be]=k(null),xe=D((N,T)=>{const O=new Date(N.timestamp).toISOString(),K=N.tags?" "+Object.entries(N.tags).filter(([,Q])=>Q).map(([Q,ue])=>`${Q}=${ue}`).join(" "):"",B=N.meta&&Object.keys(N.meta).length>0?` meta=${JSON.stringify(N.meta)}`:"",le=`${O} [${N.level.toUpperCase()}]${N.scope?` [${N.scope}]`:""}${K} ${N.message}${B}`;navigator.clipboard.writeText(le).then(()=>{be(T),setTimeout(()=>be(Q=>Q===T?null:Q),1200)})},[]),Ne=D(N=>`${N.timestamp}|${N.level}|${N.scope??""}|${N.message}`,[]);return c("div",{className:w("h-full min-h-0 flex flex-col",f),onClick:N=>N.stopPropagation(),children:[c("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[c("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),S&&t(Bt,{label:"agent",value:S}),E&&t(Bt,{label:"addon",value:E}),P!==void 0&&t(Bt,{label:"device",value:`#${P}`}),t("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:_c.map(N=>c("button",{type:"button",onClick:()=>C(N==="all"?void 0:N),className:w("px-1.5 py-0.5 capitalize transition-colors",N==="all"&&!y||y===N?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",N!=="all"&&"border-l border-border"),children:[N,N!=="all"?"+":""]},N))}),t($t,{icon:sr,label:ie?"Auto":"Paused",active:!ie,onClick:()=>{fe(N=>!N),!ie&&_.current&&_.current.scrollTo({top:0,behavior:"smooth"})}}),t($t,{icon:Oe,label:te?"Copied!":"Copy",onClick:se,disabled:Y.length===0}),t($t,{icon:Ie,label:"Clear",onClick:Pe}),c("div",{className:"relative",children:[t("input",{type:"text",value:pe,onChange:N=>L(N.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),pe&&t("button",{type:"button",onClick:()=>L(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:t(Ce,{className:"h-2.5 w-2.5"})})]}),V.length>0&&c("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",V.length," live"]})]}),g&&t("button",{type:"button",onClick:g,className:"text-foreground-subtle hover:text-foreground",children:t(Ce,{className:"h-3.5 w-3.5"})})]}),u&&(!r||!n)&&c("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!r&&c("label",{className:"flex items-center gap-1",children:[t("span",{className:"text-foreground-subtle",children:"Addon:"}),t("input",{type:"text",value:h,onChange:N=>b(N.target.value),placeholder:"all",className:"w-28 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]}),!n&&c("label",{className:"flex items-center gap-1",children:[t("span",{className:"text-foreground-subtle",children:"Device:"}),t("input",{type:"text",inputMode:"numeric",value:v,onChange:N=>x(N.target.value),placeholder:"all",className:"w-16 px-1.5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"})]})]}),c("div",{ref:_,className:w("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[ne&&c("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[t(Ee,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!ne&&Y.length===0&&t("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),Y.length>0&&t("table",{className:"w-full",children:t("tbody",{children:Y.map(N=>{const T=en[N.level]??en.info,O=T.icon,K=Ne(N),B=Z.has(K),le=N.tags&&Object.keys(N.tags).length>0,Q=N.meta&&Object.keys(N.meta).length>0,ue=le||Q;return c("tr",{className:w("hover:bg-surface-hover/30 border-b border-border/30",ue&&"cursor-pointer"),onClick:ue?()=>H(K):void 0,children:[t("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(N.timestamp).toLocaleTimeString()}),t("td",{className:w("px-1 py-1 align-top w-5",T.color),children:t(O,{className:"h-3 w-3"})}),l&&t("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:N.scope,children:N.scope?.replace(/^addon:/,"")??""}),t("td",{className:"px-2 py-1 text-foreground break-all",children:c("div",{className:"flex items-start gap-1",children:[ue&&(B?t(Qe,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):t(Le,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),c("div",{className:"flex-1 min-w-0",children:[N.message,B&&ue&&c("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[Q&&Object.entries(N.meta).filter(([,Se])=>Se!==void 0&&Se!=="").map(([Se,je])=>c("div",{children:[t("span",{className:"text-amber-400/80 font-medium",children:Se}),t("span",{className:"text-foreground-subtle",children:": "}),t("span",{className:"text-foreground break-all",children:Xr(je)})]},`m-${Se}`)),le&&Object.entries(N.tags).filter(([,Se])=>Se!==void 0).map(([Se,je])=>c("div",{children:[t("span",{className:"text-primary/70 font-medium",children:Se}),t("span",{className:"text-foreground-subtle",children:": "}),t("span",{className:"text-foreground",children:je})]},`t-${Se}`))]})]})]})}),t("td",{className:"px-1 py-1 align-top w-5",children:t($c,{copied:me===K,onCopy:()=>xe(N,K)})})]},K)})})})]})]})}function Jx({position:e="bottom",className:r,...n}){return t("div",{className:w(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",r),children:t(Es,{maxHeight:"max-h-48",...n})})}function Bt({label:e,value:r}){return c("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",r]})}function $c({copied:e,onCopy:r}){return t("button",{type:"button",title:"Copy this row",onClick:n=>{n.stopPropagation(),r()},className:w("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?t(Je,{className:"h-3 w-3"}):t(Oe,{className:"h-3 w-3"})})}function $t({icon:e,label:r,onClick:n,disabled:s,active:o}){return c("button",{type:"button",onClick:n,disabled:s,className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",o?"border-amber-500/30 bg-amber-500/10 text-amber-400":"border-border text-foreground-subtle hover:text-foreground",s&&"opacity-40 cursor-not-allowed"),children:[t(e,{className:"h-2.5 w-2.5"}),r]})}function Qc(e,r,n,s){if(s!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==s||n!==void 0&&(e.source.addonId??(e.source.type==="addon"&&typeof e.source.id=="string"?e.source.id:void 0))!==n)return!1;if(r!==void 0){const o=e.source.nodeId;if(!o||o!==r&&!o.startsWith(`${r}/`))return!1}return!0}var Gc={[F.AddonStarted]:{icon:Ut,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[F.AddonInstalled]:{icon:Wt,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[F.AddonRestarted]:{icon:nr,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[F.AddonUpdated]:{icon:En,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[F.AddonStopped]:{icon:yr,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[F.AddonUninstalled]:{icon:Ie,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[F.AddonCrashed]:{icon:bt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[F.AddonError]:{icon:Xe,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[F.DetectionPhaseTransition]:{icon:_e,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[F.DetectionResult]:{icon:Bo,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[F.DetectionEvent]:{icon:xt,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[F.DetectionCameraNative]:{icon:wr,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[F.ProviderMotion]:{icon:Nr,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[F.MotionOnMotionChanged]:{icon:Nr,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[F.MotionAnalysis]:{icon:_e,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[F.MotionZonesRaw]:{icon:_e,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[F.ProviderDetection]:{icon:wr,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[F.PipelineAudioInferenceResult]:{icon:Dn,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[F.AgentOnline]:{icon:Ut,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[F.AgentOffline]:{icon:yr,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[F.DeviceRegistered]:{icon:Wt,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[F.DeviceUnregistered]:{icon:Ie,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[F.DeviceStateChanged]:{icon:_e,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Xt(e,r){const n=Gc[e]??{icon:Ut,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===F.DeviceStateChanged&&r&&typeof r.capName=="string"){const s=r.capName;return{...n,label:s}}return n}var Fe=Object.freeze([...new Set(Object.values(F))].sort()),jc=Object.freeze([F.PipelineCameraMetricsSnapshot,F.PipelineRunnerLoadSnapshot,F.PipelineEngineMetricsSnapshot,F.PipelineInferenceResult,F.PipelineTrace,F.PipelineProgress,F.StreamBrokerMetricsSnapshot,F.MetricsNodeResourcesSnapshot,F.MetricsNodeProcessesSnapshot,F.ClusterTopologySnapshot,F.MotionAnalysis,F.MotionZonesRaw,F.DetectionResult,F.PipelineAudioInferenceResult,F.PlatformProbePhase,F.BenchmarkProgress,F.ModelDownloadProgress]),Fc=new Set(jc),zc=Object.freeze(Fe.filter(e=>!Fc.has(e)));function ut(e,r){if(e===F.DetectionPhaseTransition){const o=r.to,a=r.from,i=typeof r.source=="string"?r.source:null,l=typeof r.cooldownMs=="number"?r.cooldownMs:null,u=i?` (${i}${l?`, ${Math.round(l/1e3)}s cooldown`:""})`:"";return o==="active"?`Motion detected — phase active${u}`:o==="watching"?`Cooldown expired — phase watching${u}`:`Phase: ${String(a)} → ${String(o)}${u}`}if(e===F.DetectionResult){const a=r.frame?.detections??[];if(a.length===0)return null;const i=new Map;for(const l of a){const u=l,p=u.class??u.macroClass,m=typeof p=="string"?p:"";m&&i.set(m,(i.get(m)??0)+1)}return[...i.entries()].map(([l,u])=>u>1?`${l} ×${u}`:l).join(", ")}if(e===F.PipelineAudioInferenceResult){const a=r.frame?.detections??[];return a.length===0?null:a.map(i=>{const l=i,u=l.macroClass??l.class??l.label,p=typeof u=="string"?u:"",m=l.score;return m?`${p} (${Math.round(m*100)}%)`:p}).filter(Boolean).join(", ")}if(e===F.DetectionEvent){const o=r.label??r.class,a=r.score??r.confidence,i=[];return typeof o=="string"&&i.push(o),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===F.ProviderMotion)return r.active===!0?"motion start":"motion stop";if(e===F.DeviceStateChanged){const o=r.slice;if(o&&typeof o=="object"){const a=Object.keys(o).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===F.MotionOnMotionChanged){const o=r.detected,a=typeof r.source=="string"?r.source:null,i=o===!0?"motion start":o===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===F.ProviderDetection||e===F.DetectionCameraNative){const o=r.detections??[];if(!Array.isArray(o)||o.length===0)return(typeof r.class=="string"?r.class:null)??null;const a=new Map;for(const i of o){const l=i,u=l.class??l.macroClass,p=typeof u=="string"?u:"";p&&a.set(p,(a.get(p)??0)+1)}return[...a.entries()].map(([i,l])=>l>1?`${i} ×${l}`:i).join(", ")}const n=r.addonId,s=r.error;return s||(n?`addon: ${n}`:null)}function Wc(e){const r=e.category;return r===F.DetectionResult||r===F.PipelineAudioInferenceResult?ut(r,e.data)!==null:!0}var Uc=300;function Ts({agentId:e,addonId:r,deviceId:n,defaultCategories:s,categories:o,category:a,maxHeight:i="max-h-96",limit:l=50,showCategoryFilter:u=!0,showFilters:p=!1,liveBuffer:m,onClose:g,className:f}){const h=U(()=>s??o??zc,[s,o]),b=U(()=>[...h].sort().join(","),[h]),[v,x]=k(()=>new Set(h)),y=z(b);G(()=>{y.current!==b&&(y.current=b,x(new Set(h)))},[b,h]);const C=We(Uc),S=m??C,E=S.entries,[P,M]=k(!0),[A,R]=k(new Set),[$,q]=k(""),[V,he]=k(!1),[ee,ie]=k(""),[fe,te]=k(0),X=z(null),Z=z(null),ae=`${e??""}:${r??""}:${String(n??"")}:${a??""}`,pe=z(ae);G(()=>{pe.current!==ae&&(pe.current=ae,S.reset(),R(new Set),te(0))},[ae,S]),G(()=>{if(!V)return;const I=oe=>{const ce=Z.current;ce&&oe.target instanceof Node&&!ce.contains(oe.target)&&he(!1)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[V]);const L=U(()=>{const I={};return e&&(I.agentId=e),r&&(I.addonId=r),n!==void 0&&(I.deviceId=n),a&&(I.category=a),I},[e,r,n,a]),_=U(()=>[...v].sort(),[v]),J=U(()=>_.join(","),[_]),W=U(()=>{const I={...L,limit:l};return _.length>0&&_.length<Fe.length&&(I.category=_),I},[L,l,J,_]),{data:re,isLoading:ne}=d.systemEvents.getRecent.useQuery(W,{staleTime:3e4}),j=z(v);G(()=>{j.current=v},[v]);const Y=L;d.systemEvents.subscribe.useSubscription(Y,{onData:I=>{const oe=I;oe?.id&&Qc(oe,e,r,n)&&j.current.has(oe.category)&&S.append(oe)}});const se=z(E.length);G(()=>{const I=X.current;if(!I){se.current=E.length;return}const oe=se.current;if(se.current=E.length,!(E.length<=oe)){if(P&&I.scrollTop<=8)I.scrollTo({top:0});else if(!P&&I.scrollTop>0){const ce=I.firstElementChild?.firstElementChild,de=ce instanceof HTMLElement?ce.offsetHeight:28;I.scrollTop+=de*(E.length-oe)}}},[E.length,P]);const ve=U(()=>{const I=new Map;for(const de of re??[])I.set(de.id,de);for(const de of E)I.set(de.id,de);let oe=[...I.values()].filter(de=>v.has(de.category)).filter(Wc);fe>0&&(oe=oe.filter(de=>new Date(de.timestamp).getTime()>fe));const ce=$.trim().toLowerCase();return ce&&(oe=oe.filter(de=>{if(de.category.toLowerCase().includes(ce)||Xt(de.category,de.data).label.toLowerCase().includes(ce))return!0;const Ve=ut(de.category,de.data);if(Ve&&Ve.toLowerCase().includes(ce))return!0;try{if(new Date(de.timestamp).toLocaleTimeString().toLowerCase().includes(ce))return!0}catch{}try{if(JSON.stringify(de.data).toLowerCase().includes(ce)||JSON.stringify(de.source).toLowerCase().includes(ce))return!0}catch{}return!1})),oe.sort((de,qe)=>new Date(qe.timestamp).getTime()-new Date(de.timestamp).getTime())},[re,E,v,$,fe]),Pe=D(I=>{R(oe=>{const ce=new Set(oe);return ce.has(I)?ce.delete(I):ce.add(I),ce})},[]),H=D(I=>{x(oe=>{const ce=new Set(oe);return ce.has(I)?ce.delete(I):ce.add(I),ce})},[]),me=D(()=>{x(new Set(h)),q(""),te(0)},[h]),be=D(()=>{te(Date.now()),S.reset()},[S]),[xe,Ne]=k(!1),[N,T]=k(null),O=D(I=>{const oe=new Date(I.timestamp).toISOString(),ce=ut(I.category,I.data)??"",de=ce?` ${ce}`:"";return`${oe} [${I.category}]${de} data=${JSON.stringify(I.data)}`},[]),K=D(()=>{const I=ve.map(O);navigator.clipboard.writeText(I.join(`
|
|
33
|
-
`)).then(()=>{Ne(!0),setTimeout(()=>Ne(!1),1500)})},[ve,O]),B=D(I=>{navigator.clipboard.writeText(O(I)).then(()=>{T(I.id),setTimeout(()=>T(oe=>oe===I.id?null:oe),1200)})},[O]),le=D(()=>{x(new Set(Fe))},[]),Q=D(()=>{x(new Set)},[]),ue=U(()=>{const I=ee.trim().toLowerCase();return I?Fe.filter(oe=>oe.toLowerCase().includes(I)):Fe},[ee]),Se=Fe.length,je=v.size,hr=je===Se,Rs=hr?"All":`${je}/${Se}`;return c("div",{className:w("h-full min-h-0 flex flex-col",f),onClick:I=>I.stopPropagation(),children:[c("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[c("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&t(at,{label:"agent",value:e}),r&&t(at,{label:"addon",value:r}),n!==void 0&&t(at,{label:"device",value:`#${n}`}),a&&t(at,{label:"category",value:a}),c("button",{type:"button",onClick:()=>{M(I=>!I),!P&&X.current&&X.current.scrollTo({top:0,behavior:"smooth"})},className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",P?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[t(sr,{className:"h-2.5 w-2.5"}),P?"Auto":"Paused"]}),u&&c("div",{className:"relative",ref:Z,children:[c("button",{type:"button",onClick:()=>he(I=>!I),className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",hr?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick events to track",children:[t(yn,{className:"h-2.5 w-2.5"}),"Filter (",Rs,")"]}),V&&t(Hc,{search:ee,onSearchChange:ie,categories:ue,active:v,onToggle:H,onSelectAll:le,onSelectNone:Q,onResetDefaults:me})]}),c("button",{type:"button",onClick:me,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters to defaults",children:[t(wn,{className:"h-2.5 w-2.5"}),"Reset"]}),c("button",{type:"button",onClick:be,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[t(Ie,{className:"h-2.5 w-2.5"}),"Clear"]}),c("button",{type:"button",onClick:K,disabled:ve.length===0,className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",xe?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",ve.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[t(Oe,{className:"h-2.5 w-2.5"}),xe?"Copied!":"Copy"]}),c("div",{className:"relative",children:[t("input",{type:"text",value:$,onChange:I=>q(I.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),$&&t("button",{type:"button",onClick:()=>q(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:t(Ce,{className:"h-2.5 w-2.5"})})]}),E.length>0&&c("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",E.length," live"]})]}),g&&t("button",{type:"button",onClick:g,className:"text-foreground-subtle hover:text-foreground",children:t(Ce,{className:"h-3.5 w-3.5"})})]}),c("div",{ref:X,className:w("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[ne&&c("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[t(Ee,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!ne&&ve.length===0&&t("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),ve.length>0&&t("div",{className:"divide-y divide-border/30",children:ve.map(I=>{const oe=Xt(I.category,I.data),ce=oe.icon,de=ut(I.category,I.data),qe=A.has(I.id);return c("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>Pe(I.id),children:[t("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(I.timestamp).toLocaleTimeString()}),t(qc,{copied:N===I.id,onCopy:()=>B(I)}),c("div",{className:"flex-1 min-w-0",children:[c("div",{className:"flex items-center gap-1.5",children:[qe?t(Qe,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):t(Le,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),c("span",{className:w("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",oe.color),children:[t(ce,{className:"h-2.5 w-2.5"}),oe.label]}),I.source.nodeId&&I.source.nodeId!=="hub"&&t("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:I.source.nodeId})]}),de&&t("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:de}),qe&&c("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:[c("div",{children:[t("span",{className:"text-primary/70",children:"source"}),t("span",{className:"text-foreground-subtle",children:": "}),t("span",{className:"text-foreground",children:JSON.stringify(I.source)})]}),c("div",{children:[t("span",{className:"text-primary/70",children:"category"}),t("span",{className:"text-foreground-subtle",children:": "}),t("span",{className:"text-foreground",children:I.category})]}),Object.entries(I.data).map(([Ve,St])=>c("div",{children:[t("span",{className:"text-primary/70",children:Ve}),t("span",{className:"text-foreground-subtle",children:": "}),t("span",{className:"text-foreground break-all",children:typeof St=="object"?JSON.stringify(St):String(St)})]},Ve))]})]})]},I.id)})})]})]})}function Hc({search:e,onSearchChange:r,categories:n,active:s,onToggle:o,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return c("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:u=>u.stopPropagation(),children:[c("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[t(Ye,{className:"h-3 w-3 text-foreground-subtle"}),t("input",{type:"text",value:e,onChange:u=>r(u.target.value),placeholder:"Filter categories…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&t("button",{type:"button",onClick:()=>r(""),className:"text-foreground-subtle hover:text-foreground",children:t(Ce,{className:"h-2.5 w-2.5"})})]}),c("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[t("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),t("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),t("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),c("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&t("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(u=>{const p=s.has(u),m=Xt(u),g=m.icon;return c("button",{type:"button",onClick:()=>o(u),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[t("input",{type:"checkbox",readOnly:!0,checked:p,className:"accent-violet-500"}),c("span",{className:w("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",m.color),children:[t(g,{className:"h-2.5 w-2.5"}),m.label]}),t("span",{className:"text-foreground-subtle font-mono truncate",children:u})]},u)})]})]})}function Xx({position:e="bottom",className:r,...n}){return t("div",{className:w(e==="bottom"?"absolute bottom-0 left-0 right-0 z-10 border-t border-border bg-surface/95 backdrop-blur-sm":"absolute inset-x-2 bottom-2 z-10 rounded-lg border border-border bg-surface/95 backdrop-blur-sm shadow-xl",r),children:t(Ts,{maxHeight:"max-h-48",...n})})}function at({label:e,value:r}){return c("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",r]})}function qc({copied:e,onCopy:r}){return t("button",{type:"button",title:"Copy this event",onClick:n=>{n.stopPropagation(),r()},className:w("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?t(Je,{className:"h-3 w-3"}):t(Oe,{className:"h-3 w-3"})})}function e0({deviceId:e,className:r="",onOpenChild:n}){const s=d.useUtils(),o=d.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=d.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=d.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{s.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),s.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=d.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{s.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),u=d.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{s.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[p,m]=k(null),{available:g,adopted:f}=U(()=>{const S=o.data??[],E=M=>typeof M.metadata.rtspChannel=="number"?M.metadata.rtspChannel:Number.POSITIVE_INFINITY,P=(M,A)=>{const R=E(M),$=E(A);return R!==$?R-$:M.name.localeCompare(A.name)};return{available:S.filter(M=>!M.alreadyAdopted).sort(P),adopted:S.filter(M=>M.alreadyAdopted).sort(P)}},[o.data]),h=a.data,b=h?.lastError??null,v=h?.lastDiscoveryAt??null;async function x(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function y(S){m(S.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:S.childNativeId})}finally{m(null)}}async function C(S){if(S.adoptedDeviceId!=null){m(S.childNativeId);try{await u.mutateAsync({deviceId:e,childDeviceId:S.adoptedDeviceId})}finally{m(null)}}}return c("div",{className:`rounded-xl border border-border bg-surface ${r}`,children:[c("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[c("div",{className:"min-w-0",children:[t("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),c("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",t("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",t("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),c("button",{type:"button",onClick:x,disabled:i.isPending,className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-2 py-1.5 sm:px-3 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 shrink-0",children:[i.isPending?t(Ee,{className:"h-3.5 w-3.5 animate-spin"}):t(nr,{className:"h-3.5 w-3.5"}),t("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),b?c("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[t(Xe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),c("span",{children:["Last refresh failed: ",b]})]}):null,o.isLoading?t("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:t(Ee,{className:"h-5 w-5 animate-spin"})}):g.length===0&&f.length===0?t("div",{className:"px-5 py-8 text-center text-xs text-foreground-subtle",children:"No channels reported by the hub yet. Click Refresh to enumerate."}):c(ge,{children:[g.length>0?t(rn,{title:"Available to add",count:g.length,tone:"primary",children:g.map(S=>t(nn,{child:S,busy:p===S.childNativeId,onAdopt:y,onRelease:C,onOpenChild:n},S.childNativeId))}):null,f.length>0?t(rn,{title:"Already adopted",count:f.length,tone:"muted",children:f.map(S=>t(nn,{child:S,busy:p===S.childNativeId,onAdopt:y,onRelease:C,onOpenChild:n},S.childNativeId))}):null]}),v!=null?c("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(v).toLocaleString()]}):null]})}function rn({title:e,count:r,tone:n,children:s}){return c("div",{className:"border-t border-border",children:[c("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${n==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[t("span",{className:"font-semibold",children:e}),t("span",{className:"font-mono",children:r})]}),t("div",{className:"divide-y divide-border",children:s})]})}function nn({child:e,busy:r,onAdopt:n,onRelease:s,onOpenChild:o}){return c("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 sm:px-5 sm:py-3 sm:flex-nowrap sm:gap-3",children:[c("div",{className:"min-w-0 flex-1",children:[c("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t(Vc,{status:e.status}),t("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?t("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Doorbell"}):null,e.metadata.isBattery?t("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Battery"}):null,e.metadata.isMultifocal?t("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),c("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle",children:[typeof e.metadata.rtspChannel=="number"?c("span",{children:["ch ",t("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?t("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?c("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?c("div",{className:"flex items-center gap-2",children:[o&&e.adoptedDeviceId!==null?c("button",{type:"button",onClick:()=>o(e.adoptedDeviceId),className:"inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors",title:"Open device detail",children:[t(An,{className:"h-3.5 w-3.5"}),"Open"]}):null,c("button",{type:"button",onClick:()=>{s(e)},disabled:r,className:"inline-flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50",children:[r?t(Ee,{className:"h-3.5 w-3.5 animate-spin"}):t(Ie,{className:"h-3.5 w-3.5"}),"Remove"]})]}):c("button",{type:"button",onClick:()=>{n(e)},disabled:r,className:"inline-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",children:[r?t(Ee,{className:"h-3.5 w-3.5 animate-spin"}):t(ar,{className:"h-3.5 w-3.5"}),"Add"]})]})}function Vc({status:e}){switch(e){case"online":return c("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-500",children:[t(Tn,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return c("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-500",children:[t(rr,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return c("span",{className:"inline-flex items-center gap-1 rounded-full border border-destructive/40 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive",children:[t(qo,{className:"h-2.5 w-2.5"})," offline"]});case"unknown":default:return c("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-surface px-2 py-0.5 text-[10px] font-medium text-foreground-subtle",children:[t(vn,{className:"h-2.5 w-2.5"})," unknown"]})}}function Kc(e,r){if(!e||typeof e!="object")return!1;const n=e;if(n.category!==F.DeviceStateChanged)return!1;const s=n.data;return!(!s||typeof s!="object"||s.deviceId!==r||typeof s.capName!="string"||!s.slice||typeof s.slice!="object")}function Qt(e){if(!e||typeof e!="object")return null;const r=e,n=typeof r.id=="string"?r.id:null,s=typeof r.timestamp=="string"?r.timestamp:null,o=r.data;return!n||!s||!o||typeof o!="object"||typeof o.capName!="string"||!o.slice||typeof o.slice!="object"?null:{id:n,timestamp:s,capName:o.capName,slice:o.slice}}var Zc=300,Yc=Object.freeze([...new Set(Ys.filter(e=>e.scope==="device").map(e=>e.name))].sort());function Jc({deviceId:e,defaultCaps:r,maxHeight:n="max-h-96",limit:s=50,liveBuffer:o,onClose:a,className:i}){const l=U(()=>new Set(r??[]),[r]),[u,p]=k(l),[m,g]=k(""),[f,h]=k(!0),[b,v]=k(new Set),[x,y]=k(0),[C,S]=k(!1),[E,P]=k(""),M=z(null),A=We(Zc),R=o??A,$=R.entries,q=z(null),V=z(e);G(()=>{V.current!==e&&(V.current=e,R.reset(),v(new Set),y(0))},[e,R]);const he=U(()=>({deviceId:e,category:F.DeviceStateChanged,limit:s}),[e,s]),{data:ee,isLoading:ie}=d.systemEvents.getRecent.useQuery(he,{staleTime:3e4}),fe=z(u);G(()=>{fe.current=u},[u]),d.systemEvents.subscribe.useSubscription({deviceId:e,category:F.DeviceStateChanged},{onData:N=>{if(!Kc(N,e))return;const T=Qt(N);if(!T)return;const O=fe.current;O.size>0&&!O.has(T.capName)||R.append(T)}});const te=z($.length);G(()=>{const N=q.current;if(!N){te.current=$.length;return}const T=te.current;if(te.current=$.length,!($.length<=T)){if(f&&N.scrollTop<=8)N.scrollTo({top:0});else if(!f&&N.scrollTop>0){const O=N.firstElementChild?.firstElementChild,K=O instanceof HTMLElement?O.offsetHeight:28,B=$.length-T;N.scrollTop+=K*B}}},[$.length,f]);const X=U(()=>{const N=new Map;for(const K of ee??[]){const B=Qt(K);B&&N.set(B.id,B)}for(const K of $)N.set(K.id,K);let T=[...N.values()];x>0&&(T=T.filter(K=>new Date(K.timestamp).getTime()>x)),u.size>0&&(T=T.filter(K=>u.has(K.capName)));const O=m.trim().toLowerCase();return O&&(T=T.filter(K=>{if(K.capName.toLowerCase().includes(O))return!0;try{if(new Date(K.timestamp).toLocaleTimeString().toLowerCase().includes(O))return!0}catch{}try{if(Object.entries(K.slice).map(([le,Q])=>`${le}=${Gt(Q)}`).join(" · ").toLowerCase().includes(O))return!0}catch{}try{if(JSON.stringify(K.slice).toLowerCase().includes(O))return!0}catch{}return!1})),T.sort((K,B)=>new Date(B.timestamp).getTime()-new Date(K.timestamp).getTime())},[ee,$,u,m,x]),Z=U(()=>{const N=new Set(Yc);for(const T of ee??[]){const O=Qt(T);O&&N.add(O.capName)}for(const T of $)N.add(T.capName);return[...N].sort()},[ee,$]),ae=D(N=>{v(T=>{const O=new Set(T);return O.has(N)?O.delete(N):O.add(N),O})},[]),pe=D(N=>{p(T=>{const O=new Set(T);return O.has(N)?O.delete(N):O.add(N),O})},[]),L=D(()=>{p(new Set(r??[])),g("")},[r]),_=D(()=>{y(Date.now()),R.reset()},[R]),[J,W]=k(!1),[re,ne]=k(null),j=D(N=>`${new Date(N.timestamp).toISOString()} [${N.capName}] slice=${JSON.stringify(N.slice)}`,[]),Y=D(()=>{const N=X.map(j);navigator.clipboard.writeText(N.join(`
|
|
34
|
-
`)).then(()=>{W(!0),setTimeout(()=>W(!1),1500)})},[X,j]),se=D(N=>{navigator.clipboard.writeText(j(N)).then(()=>{ne(N.id),setTimeout(()=>ne(T=>T===N.id?null:T),1200)})},[j]),ve=D(()=>{p(new Set(Z))},[Z]),Pe=D(()=>{p(new Set)},[]),H=U(()=>{const N=E.trim().toLowerCase();return N?Z.filter(T=>T.toLowerCase().includes(N)):Z},[E,Z]),me=Z.length,be=u.size,xe=be===0||be===me,Ne=xe?"All":`${be}/${me}`;return G(()=>{if(!C)return;const N=T=>{const O=M.current;O&&!O.contains(T.target)&&S(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[C]),c("div",{className:w("h-full min-h-0 flex flex-col",i),onClick:N=>N.stopPropagation(),children:[c("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[c("div",{className:"flex items-center gap-2 flex-wrap",children:[t("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),t(Xc,{label:"device",value:`#${e}`}),c("button",{type:"button",onClick:()=>{h(N=>!N),!f&&q.current&&q.current.scrollTo({top:0,behavior:"smooth"})},className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",f?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[t(sr,{className:"h-2.5 w-2.5"}),f?"Auto":"Paused"]}),c("div",{className:"relative",ref:M,children:[c("button",{type:"button",onClick:()=>S(N=>!N),className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",xe?"border-border text-foreground-subtle hover:text-foreground":"border-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to track",children:[t(yn,{className:"h-2.5 w-2.5"}),"Filter (",Ne,")"]}),C&&t(ed,{search:E,onSearchChange:P,caps:H,active:u,onToggle:pe,onSelectAll:ve,onSelectNone:Pe,onResetDefaults:L})]}),c("button",{type:"button",onClick:L,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Reset filters",children:[t(wn,{className:"h-2.5 w-2.5"}),"Reset"]}),c("button",{type:"button",onClick:_,className:"inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground transition-colors",title:"Clear visible entries",children:[t(Ie,{className:"h-2.5 w-2.5"}),"Clear"]}),c("button",{type:"button",onClick:Y,disabled:X.length===0,className:w("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",J?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",X.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible state changes",children:[t(Oe,{className:"h-2.5 w-2.5"}),J?"Copied!":"Copy"]}),c("div",{className:"relative",children:[t("input",{type:"text",value:m,onChange:N=>g(N.target.value),placeholder:"Search…",className:"w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50"}),m&&t("button",{type:"button",onClick:()=>g(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:t(Ce,{className:"h-2.5 w-2.5"})})]}),$.length>0&&c("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",$.length," live"]})]}),a&&t("button",{type:"button",onClick:a,className:"text-foreground-subtle hover:text-foreground",children:t(Ce,{className:"h-3.5 w-3.5"})})]}),c("div",{ref:q,className:w("flex-1 min-h-0 overflow-auto text-[10px]",n),children:[ie&&c("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[t(Ee,{className:"h-3.5 w-3.5 animate-spin"}),"Loading state changes..."]}),!ie&&X.length===0&&t("div",{className:"py-4 text-center text-foreground-subtle",children:"No state changes"}),X.length>0&&t("div",{className:"divide-y divide-border/30",children:X.map(N=>{const T=b.has(N.id),O=Object.entries(N.slice),K=O.slice(0,3).map(([B,le])=>`${B}=${Gt(le)}`).join(" · ");return c("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>ae(N.id),children:[t("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date(N.timestamp).toLocaleTimeString()}),t(td,{copied:re===N.id,onCopy:()=>se(N)}),c("div",{className:"flex-1 min-w-0",children:[c("div",{className:"flex items-center gap-1.5",children:[T?t(Qe,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):t(Le,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),t("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-2 py-0.5 text-[9px] font-medium",children:N.capName}),O.length>3&&c("span",{className:"text-[9px] text-foreground-subtle",children:["+",O.length-3," more"]})]}),K&&t("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5 truncate",children:K}),T&&t("div",{className:"mt-1 ml-5 text-[9px] bg-surface rounded px-2 py-1.5 space-y-0.5 font-mono overflow-x-auto",children:O.length===0?t("div",{className:"text-foreground-subtle italic",children:"empty slice"}):O.map(([B,le])=>c("div",{children:[t("span",{className:"text-primary/70",children:B}),t("span",{className:"text-foreground-subtle",children:": "}),t("span",{className:"text-foreground break-all",children:Gt(le)})]},B))})]})]},N.id)})})]})]})}function Gt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Xc({label:e,value:r}){return c("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",r]})}function ed({search:e,onSearchChange:r,caps:n,active:s,onToggle:o,onSelectAll:a,onSelectNone:i,onResetDefaults:l}){return c("div",{className:"absolute z-20 top-full mt-1 left-0 w-72 max-h-80 rounded-md border border-border bg-surface shadow-lg flex flex-col",onClick:u=>u.stopPropagation(),children:[c("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[t(Ye,{className:"h-3 w-3 text-foreground-subtle"}),t("input",{type:"text",value:e,onChange:u=>r(u.target.value),placeholder:"Filter caps…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&t("button",{type:"button",onClick:()=>r(""),className:"text-foreground-subtle hover:text-foreground",children:t(Ce,{className:"h-2.5 w-2.5"})})]}),c("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[t("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),t("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),t("button",{type:"button",onClick:l,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),c("div",{className:"overflow-y-auto flex-1",children:[n.length===0&&t("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),n.map(u=>{const p=s.has(u);return c("button",{type:"button",onClick:()=>o(u),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[t("input",{type:"checkbox",readOnly:!0,checked:p,className:"accent-violet-500"}),t("span",{className:"inline-flex items-center gap-1 rounded-full border border-violet-500/30 bg-violet-500/15 text-violet-400 px-1.5 py-0.5 text-[9px] font-medium shrink-0",children:u})]},u)})]})]})}function td({copied:e,onCopy:r}){return t("button",{type:"button",title:"Copy this state change",onClick:n=>{n.stopPropagation(),r()},className:w("rounded p-0.5 transition-colors mt-0.5",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?t(Je,{className:"h-3 w-3"}):t(Oe,{className:"h-3 w-3"})})}var jt=500,rd=[{id:"logs",label:"Logs",icon:io},{id:"events",label:"Events",icon:vt},{id:"state",label:"State",icon:lo}];function t0({deviceId:e,defaultEventCategories:r,defaultStateCaps:n,initialTab:s="events",className:o,maxHeight:a="max-h-96"}){const[i,l]=k(s),u=We(jt),p=We(jt),m=We(jt),g=u.reset,f=p.reset,h=m.reset;return G(()=>{g(),f(),h()},[e,g,f,h]),c("div",{className:w("flex flex-col h-full min-h-0",o),children:[t("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:rd.map(({id:b,label:v,icon:x})=>c("button",{type:"button",onClick:()=>l(b),className:w("inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium transition-colors",i===b?"bg-primary/15 text-primary border border-primary/30":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover border border-transparent"),children:[t(x,{className:"h-3.5 w-3.5"}),v]},b))}),c("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&t(Es,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:u}),i==="events"&&t(Ts,{deviceId:e,defaultCategories:r,maxHeight:a,showCategoryFilter:!0,liveBuffer:p}),i==="state"&&t(Jc,{deviceId:e,defaultCaps:n,maxHeight:a,liveBuffer:m})]})]})}function r0({label:e,icon:r,title:n="Confirm action",description:s,confirmLabel:o,triggerVariant:a="outline",confirmVariant:i="danger",size:l="sm",disabled:u,className:p,action:m,onSuccess:g}){const[f,h]=k(!1),[b,v]=k(!1),[x,y]=k(null),C=async()=>{y(null),v(!0);try{const S=await m();g?.(S),h(!1)}catch(S){y(S instanceof Error?S.message:String(S))}finally{v(!1)}};return c(ge,{children:[c(dt,{type:"button",variant:a,size:l,disabled:u,onClick:()=>{y(null),h(!0)},className:p,children:[r&&t(r,{className:"h-3.5 w-3.5"}),e]}),t(ba,{open:f,onOpenChange:S=>!b&&h(S),children:c(Vn,{children:[c(xa,{children:[c(wa,{className:"flex items-center gap-2",children:[t(Xe,{className:"h-4 w-4 text-amber-400"}),n]}),typeof s=="string"?t(Na,{children:s}):s]}),x&&t("div",{className:w("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:x}),c(ya,{children:[t(dt,{type:"button",variant:"ghost",size:l,disabled:b,onClick:()=>h(!1),children:"Cancel"}),c(dt,{type:"button",variant:i,size:l,disabled:b,onClick:()=>{C()},children:[b&&t(Ee,{className:"h-3.5 w-3.5 animate-spin"}),o??e]})]})]})})]})}function it({direction:e,icon:r,disabled:n,className:s,variant:o,onMove:a,onStart:i,onStop:l}){const[u,p]=k(null),[m,g]=k(!1),f=D(C=>{if(n)return;C.currentTarget.setPointerCapture(C.pointerId),p(Date.now()),g(!1);const S=setTimeout(()=>{g(!0),i(e)},250);C.currentTarget.dataset.timer=String(S)},[e,n,i]),h=D(C=>{const S=Number(C.currentTarget.dataset.timer);S&&clearTimeout(S),C.currentTarget.dataset.timer="",m?l():u!==null&&a(e),p(null),g(!1)},[m,e,a,l,u]),b=D(C=>{const S=Number(C.currentTarget.dataset.timer);S&&clearTimeout(S),C.currentTarget.dataset.timer="",m&&l(),p(null),g(!1)},[m,l]),v=o==="panel"?"h-9 w-9":"h-7 w-7",x=o==="panel"?"h-4 w-4":"h-3.5 w-3.5";return t("button",{type:"button",disabled:n,onPointerDown:f,onPointerUp:h,onPointerCancel:b,className:w("flex items-center justify-center rounded transition-colors disabled:opacity-40",o==="panel"?"text-foreground hover:bg-surface-hover active:bg-surface-hover/80":"text-white hover:bg-white/15 active:bg-white/25",v,s),title:e,children:t(r,{className:x})})}function n0({controls:e,mode:r="overlay",showPresets:n,showZoom:s=!0,showHome:o=!0,className:a}){const{move:i,startContinuous:l,stopContinuous:u,zoom:p,goHome:m,goToPreset:g,presets:f,busy:h,error:b}=e,[v,x]=k(!1),y=(n??f.length>0)&&f.length>0,C=r==="panel",S=C?"flex flex-col items-stretch gap-2 w-full h-full p-3":"pointer-events-auto absolute top-3 right-3 z-10 flex flex-col items-end gap-2",E=w(C?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",h&&"ring-1 ring-primary/40"),P=C?"h-9 w-9":"h-7 w-7",M=C?"h-4 w-4":"h-3.5 w-3.5",A=C?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",R=C?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return c("div",{className:w(S,a),children:[b&&c("div",{className:"rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center",children:["PTZ: ",b]}),c("div",{className:w(E,C&&"justify-center"),children:[c("div",{className:"grid grid-cols-3 gap-0.5",children:[t("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),t(it,{direction:"up",icon:Cn,variant:r,onMove:i,onStart:l,onStop:u}),t("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),t(it,{direction:"left",icon:ho,variant:r,onMove:i,onStart:l,onStop:u}),t("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),t(it,{direction:"right",icon:bo,variant:r,onMove:i,onStart:l,onStop:u}),t("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),t(it,{direction:"down",icon:Sn,variant:r,onMove:i,onStart:l,onStop:u}),t("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"})]}),(s||o)&&t("div",{className:R}),c("div",{className:"flex flex-col gap-0.5",children:[s&&c(ge,{children:[t("button",{type:"button",onClick:()=>p("in"),disabled:h,title:"Zoom in",className:w("flex items-center justify-center rounded disabled:opacity-40",P,A),children:t(vo,{className:M})}),t("button",{type:"button",onClick:()=>p("out"),disabled:h,title:"Zoom out",className:w("flex items-center justify-center rounded disabled:opacity-40",P,A),children:t(xo,{className:M})})]}),o&&t("button",{type:"button",onClick:()=>m(),disabled:h,title:"Go home",className:w("flex items-center justify-center rounded disabled:opacity-40",P,A),children:t(bn,{className:M})})]}),y&&c("div",{className:"relative",children:[c("button",{type:"button",onClick:()=>x($=>!$),disabled:h,className:w("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",C?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",t(Qe,{className:w("h-3 w-3 transition-transform",v&&"rotate-180")})]}),v&&t("div",{className:w("absolute right-0 min-w-[140px] rounded-lg shadow-xl py-1 z-20",C?"bottom-full mb-1 bg-surface border border-border":"top-full mt-1 border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:f.map($=>t("button",{type:"button",onClick:()=>{g($.id),x(!1)},disabled:h,className:w("block w-full px-3 py-1.5 text-left text-[10px] disabled:opacity-40",C?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15"),children:$.name||$.id},$.id))})]})]})]})}function nd(e,r){const n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function s0({trpc:e,deviceId:r,deviceName:n,size:s="sm",className:o}){const[a,i]=k(!1),[l,u]=k(!1),[p,m]=k(null),g=n.replace(/[^a-zA-Z0-9_.-]+/g,"_"),f=D(async P=>{i(!0),m(null),u(!1);try{const M=await e.snapshot.getSnapshot.query({deviceId:r,force:!0});if(!M)throw new Error("No snapshot available");const A=`data:${M.contentType};base64,${M.base64}`;if(P==="copy")try{await navigator.clipboard.writeText(A)}catch{throw new Error("Clipboard unavailable")}else{const R=M.contentType.includes("png")?"png":"jpg",$=new Date().toISOString().replace(/[:.]/g,"-");nd(`${g}-${$}.${R}`,A)}u(!0),setTimeout(()=>u(!1),1500)}catch(M){m(M instanceof Error?M.message:String(M))}finally{i(!1)}},[e,r,g]),h=s==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[b,v]=k(null),[x,y]=k(!1),C=()=>{y(!1);const P=setTimeout(()=>{y(!0),f("copy")},600);v(P)},S=()=>{b&&(clearTimeout(b),v(null)),x||f("download")},E=()=>{b&&(clearTimeout(b),v(null))};return c("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:C,onPointerUp:S,onPointerLeave:E,onPointerCancel:E,className:w("inline-flex items-center justify-center rounded-lg font-medium border border-border","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","disabled:opacity-50 transition-colors",h,p&&"border-danger/40 text-danger",o),children:[a?t(Ee,{className:"h-3.5 w-3.5 animate-spin"}):l?t(Je,{className:"h-3.5 w-3.5 text-success"}):t(or,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function sd(e){const r=Date.now()-e;return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:`${Math.floor(r/864e5)}d ago`}function o0({history:e,limit:r=5,latestIsFresh:n,className:s}){if(e.length===0)return null;const o=n?co:vt,a=e.slice(0,r);return c("div",{className:w("rounded-lg border border-border bg-surface px-3 py-2",s),children:[c("div",{className:"flex items-center gap-2 mb-2",children:[t(o,{className:w("h-4 w-4 text-amber-400",n&&"animate-pulse")}),t("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),t("span",{className:"ml-auto rounded-full bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle border border-border",children:e.length})]}),t("ul",{className:"space-y-1",children:a.map(i=>c("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[t("span",{className:"text-foreground",children:sd(i.timestamp)}),t("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function a0({items:e,header:r,triggerClassName:n,title:s="More actions"}){const[o,a]=k(!1),i=e.filter(l=>!l.hidden);return i.length===0?null:c(Pa,{open:o,onOpenChange:a,children:[t(Aa,{title:s,className:w("inline-flex items-center justify-center rounded-lg p-2","text-foreground-subtle hover:text-foreground hover:bg-surface-hover","border border-transparent transition-colors",n),children:t(Nn,{className:"h-4 w-4"})}),c(Da,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[r&&t("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:r}),t("ul",{className:"space-y-0.5",children:i.map((l,u)=>c("li",{children:[l.separatorBefore&&u>0&&t("div",{className:"my-1 h-px bg-border"}),c("button",{type:"button",disabled:l.disabled,onClick:()=>{l.disabled||(l.onClick(),a(!1))},className:w("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px]","transition-colors disabled:opacity-40 disabled:cursor-not-allowed",l.danger?"text-foreground hover:bg-danger/10 hover:text-danger":"text-foreground hover:bg-surface-hover"),children:[l.icon&&t(l.icon,{className:w("h-3.5 w-3.5 shrink-0 mt-0.5",l.danger&&"text-danger/80")}),c("span",{className:"flex-1 min-w-0",children:[t("span",{className:"block leading-tight",children:l.label}),l.description&&t("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:l.description})]})]})]},l.id))})]})]})}var Is=Be("camstack:zone-editing",null);function i0({children:e}){const[r,n]=k(!1),[s,o]=k(null),[a,i]=k(null),[l,u]=k(null),p=D(C=>{n(C),C||(o(null),i(null),u(null))},[]),m=D(C=>{o(C)},[]),g=D(C=>{i(C)},[]),f=D(C=>{n(!0),i(null),o(C),u(null)},[]),h=D(()=>{n(!1),o(null),i(null),u(null)},[]),b=D(C=>{i(C.id),u(C)},[]),v=D(C=>{u(S=>S===null?S:{...S,...C})},[]),x=D(()=>{u(null)},[]),y=U(()=>({editing:r,drawingKind:s,selectedZoneId:a,editingDraft:l,setEditing:p,setDrawingKind:m,setSelectedZoneId:g,startDrawing:f,exitEditing:h,enterDraft:b,updateDraft:v,discardDraft:x}),[r,s,a,l,p,m,g,f,h,b,v,x]);return t(Is.Provider,{value:y,children:e})}function l0(){return we(Is)}var sn=500,od=800;function lt(e,r,n){try{const s=e.live;if(!s)return null;const o=s.onEvent;return!o||typeof o.subscribe!="function"?null:o.subscribe({category:r},{onData:n})}catch{return null}}function ct(e,r){return e?.id===r}function c0(e,r){const[n,s]=k(null),[o,a]=k(null),[i,l]=k(null),[u,p]=k("watching"),m=z(void 0),g=z(void 0),f=z(void 0);return G(()=>{if(r===null)return;const h=lt(e,"detection.motion-analysis",b=>{const v=b;if(!ct(v?.source,r))return;const x=v.data;!x?.regions||x.regions.length===0||(s({zones:x.regions.map(y=>({...y.bbox,intensity:y.intensity})),frameWidth:x.frameWidth,frameHeight:x.frameHeight}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>s(null),sn))});return()=>{h?.unsubscribe(),m.current&&clearTimeout(m.current)}},[e,r]),G(()=>{if(r===null)return;const h=lt(e,"detection.motion-zones-raw",b=>{const v=b;if(!ct(v?.source,r))return;const x=v.data;x?.zones&&(a({boxes:x.zones.map(y=>({bbox:y.bbox,changeScore:y.changeScore})),frameWidth:x.frameSize?.width??0,frameHeight:x.frameSize?.height??0,motionScore:x.zones.length>0?x.zones.reduce((y,C)=>y+C.changeScore,0)/x.zones.length:0}),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>a(null),sn))});return()=>{h?.unsubscribe(),g.current&&clearTimeout(g.current)}},[e,r]),G(()=>{if(r===null)return;const h=lt(e,"detection.result",b=>{const v=b;if(!ct(v?.source,r))return;const x=v.data?.frame;x?.detections?.length&&(l({detections:x.detections,frameWidth:x.width,frameHeight:x.height}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>l(null),od))});return()=>{h?.unsubscribe(),f.current&&clearTimeout(f.current)}},[e,r]),G(()=>{if(r===null)return;const h=lt(e,"detection.phase-transition",b=>{const v=b;ct(v?.source,r)&&v.data?.to&&p(v.data.to)});return()=>{h?.unsubscribe()}},[e,r]),{motion:n,motionRaw:o,detection:i,phase:u}}function d0(e,r,n=5e3){const[s,o]=k([]);G(()=>{if(r===null)return;let f=!1;const h=()=>{e.webrtcSession.listStreams.query({deviceId:r}).then(v=>{f||o(v)}).catch(()=>{})};h();const b=setInterval(h,n);return()=>{f=!0,clearInterval(b)}},[e,r,n]);const[a,i]=k(null);G(()=>{if(r===null)return;let f=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:r}).then(h=>{f||!h||i({phase:h.phase,detectionFps:h.actualFps,avgInferenceMs:h.avgInferenceTimeMs,droppedFrames:h.droppedFrames})}).catch(()=>{}),()=>{f=!0}},[e,r]),yt("pipeline.camera-metrics-snapshot",f=>{if(r===null)return;const h=f.data;h.deviceId!==r||!h.metrics||i({phase:h.metrics.phase,detectionFps:h.metrics.actualFps,avgInferenceMs:h.metrics.avgInferenceTimeMs,droppedFrames:h.metrics.droppedFrames})});const{streams:l,hasWebrtc:u}=U(()=>r===null||s.length===0?{streams:[],hasWebrtc:!1}:{streams:s.map(h=>({id:h.id,label:h.label,target:h.target,status:h.status,inputFps:h.inputFps,decodeFps:h.decodeFps,bitrateKbps:h.bitrateKbps})),hasWebrtc:!0},[r,s]),p=D(async(f,h)=>{if(r===null)throw new Error("No device selected");const b=await e.webrtcSession.createSession.mutate({deviceId:r,target:f,hints:h});return{sessionId:b.sessionId,sdpOffer:b.sdpOffer}},[e,r]),m=D(async(f,h)=>{if(r===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:r,sessionId:f,sdpAnswer:h})},[e,r]),g=D(async f=>{r!==null&&await e.webrtcSession.closeSession.mutate({deviceId:r,sessionId:f}).catch(()=>{})},[e,r]);return{streams:l,hasWebrtc:u,pipelineMetrics:a,createSession:p,sendAnswer:m,closeSession:g}}var on={up:{pan:0,tilt:1},down:{pan:0,tilt:-1},left:{pan:-1,tilt:0},right:{pan:1,tilt:0},"up-left":{pan:-1,tilt:1},"up-right":{pan:1,tilt:1},"down-left":{pan:-1,tilt:-1},"down-right":{pan:1,tilt:-1}};function u0(e,r,n){const s=n?.defaultSpeed??.5,o=n?.pulseMs??250,a=n?.enabled??!0,l=wt(e,a?r:null)?.ptz,[u,p]=k([]),[m,g]=k(!1),[f,h]=k(null),b=D(async()=>{if(!(!a||!l))try{const M=await l.getPresets({});p(M)}catch(M){const A=M instanceof Error?M.message:String(M);if(A.includes("provider not available")||A.includes("no 'ptz' binding"))return;h(A)}},[l,a]);G(()=>{b()},[b]);const v=D(async M=>{if(!(!a||!l)){h(null),g(!0);try{return await M()}catch(A){h(A instanceof Error?A.message:String(A));return}finally{g(!1)}}},[a,l]),x=D(async(M,A)=>{if(!l)return;const R=on[M],$=A??s;await v(async()=>{await l.move({pan:R.pan,tilt:R.tilt,speed:$}),await new Promise(q=>setTimeout(q,o)),await l.stop({})})},[l,s,o,v]),y=D(async(M,A)=>{if(!l)return;const R=on[M],$=A??s;await v(()=>l.continuousMove({pan:R.pan,tilt:R.tilt,speed:$}))},[l,s,v]),C=D(async()=>{l&&await v(()=>l.stop({}))},[l,v]),S=D(async(M,A)=>{if(!l)return;const R=M==="in"?1:-1,$=A??s;await v(async()=>{await l.move({zoom:R,speed:$}),await new Promise(q=>setTimeout(q,o)),await l.stop({})})},[l,s,o,v]),E=D(async()=>{l&&await v(()=>l.goHome({}))},[l,v]),P=D(async M=>{l&&await v(()=>l.goToPreset({presetId:M}))},[l,v]);return{move:x,startContinuous:y,stopContinuous:C,zoom:S,goHome:E,goToPreset:P,presets:u,refreshPresets:b,busy:m,error:f}}function p0(e){const r=e?.deviceId??null,n=e?.historyLimit??20,s=ds("doorbell.onPressed",r!==null?i=>i.deviceId===r:void 0),[o,a]=k([]);return G(()=>{s&&a(i=>{if(i.length>0&&i[0].deviceId===s.deviceId&&i[0].timestamp===s.timestamp)return i;const l=[s,...i];return l.length>n?l.slice(0,n):l})},[s,n]),{latest:s??null,history:o}}function m0(e){const r=He(),n=U(()=>e?JSON.stringify(e):"",[e]),[s,o]=k(()=>r.listDevices(e));return G(()=>{const a=()=>{o(r.listDevices(e))};a();let i=null,l=null;try{i=r.onDeviceAdded(a),l=r.onDeviceRemoved(a)}catch{}const u=r.subscribeConnectionEvents(p=>{p==="connected"&&a()});return()=>{i?.(),l?.(),u()}},[r,e,n]),s}function g0(e){const r=He(),[n,s]=k(()=>e===null?null:r.getDevice(e));return G(()=>{if(e===null){s(null);return}const o=()=>{s(r.getDevice(e))};o();let a=null,i=null;try{a=r.onDeviceAdded(o),i=r.onDeviceRemoved(o)}catch{}const l=r.subscribeConnectionEvents(u=>{u==="connected"&&o()});return()=>{a?.(),i?.(),l()}},[r,e]),n}function f0(e,r,n){const s=He();return un({queryKey:e,queryFn:()=>r(s)(),...n})}function h0(e,r){const n=He();return Ws({mutationFn:s=>e(n)(s),...r})}function b0(e,r){const n=He(),s=tr(),[o,a]=k(n.connectionVersion);G(()=>n.subscribeConnectionEvents((u,p)=>{u==="connected"&&a(p)}),[n]);const i=r.join("|"),l=JSON.stringify(e);G(()=>{const u=[],p=()=>{const m=JSON.parse(l),f=m.length===1&&Array.isArray(m[0])?m:[m];s.invalidateQueries({queryKey:f})};p();for(const m of i.split("|"))if(m)try{u.push(n.subscribeEvent(m,p))}catch{}return()=>{for(const m of u)m()}},[n,s,i,l,o])}export{jx as AddonGlobalSettingsForm,du as AgentStepEditor,Mu as AppShell,Kx as AudioClassificationList,Vx as AudioLevelWaveform,qx as AudioWaveform,Qd as BTN_COMPACT,jd as BTN_COMPACT_DANGER,Gd as BTN_COMPACT_PRIMARY,Fd as BTN_COMPACT_WARNING,Ke as Badge,Ri as BatteryBadge,ts as BottomSheet,au as Breadcrumb,dt as Button,Ud as CHIP_ACTIVE,Wd as CHIP_BASE,Hd as CHIP_INACTIVE,rt as CLASS_COLORS,Cc as CameraStreamPlayer,zn as Card,qt as Checkbox,Su as CodeBlock,ga as CollapsibleCard,pc as ConfigFormBuilder,Ct as ConfigFormField,cr as ConfigSchemaField,r0 as ConfirmActionButton,wu as ConfirmDialogProvider,ju as CustomFieldRenderersProvider,nl as DEFAULT_COLOR,Pu as DataTable,Lu as DetectionCanvas,fc as DetectionOverlay,_u as DetectionResultTree,vl as DevShell,t0 as DeviceActivityPanel,Au as DeviceCard,Fu as DeviceContextProvider,Du as DeviceGrid,Zt as DeviceItem,Tu as DeviceList,ba as Dialog,Vn as DialogContent,Na as DialogDescription,ya as DialogFooter,xa as DialogHeader,wa as DialogTitle,Zd as DialogTrigger,e0 as DiscoveryPanel,o0 as DoorbellRecentPanel,Ca as Dropdown,ka as DropdownContent,Ma as DropdownItem,Sa as DropdownTrigger,yu as EmptyState,Ts as EventStream,ku as FilterBar,Xx as FloatingEventStream,Jx as FloatingLogStream,ou as FloatingPanel,vu as FormField,Ad as GRID_GAP,Td as GRID_PAIRED,Ed as GRID_QUICK_STATS,zd as INPUT_COMPACT,mt as IconButton,Bu as ImageSelector,$u as InferenceConfigSelector,Ht as Input,a0 as KebabMenu,Cu as KeyValueList,Dd as LIST_ROW,Wn as Label,Es as LogStream,ml as LoginForm,Ea as MobileDrawer,Wl as NodeMultiSelectField,gu as NodePicker,zl as NodeSelectField,Pr as PHASE_CONFIG,n0 as PTZOverlay,xu as PageHeader,Yx as PhaseIcon,Ru as PipelineBuilder,Iu as PipelineRuntimeSelector,Pt as PipelineStep,uu as PipelineTreeMatrix,Fx as PlayerOverlaysProvider,Pa as Popover,Da as PopoverContent,Aa as PopoverTrigger,hu as ProviderBadge,Zx as ResponseLog,Md as SECTION_BODY,Sd as SECTION_CARD,kd as SECTION_HEADER,Id as SPLIT_PANEL_OUTER,Rd as SPLIT_PANEL_SIDE,Pd as STACK_GAP,as as ScrollArea,gt as Select,Va as SemanticBadge,Un as Separator,_r as Sidebar,Lr as SidebarItem,Ze as Skeleton,iu as SlideOverPanel,s0 as SnapshotButton,Nu as StatCard,Jc as StateValuesStream,fu as StatusBadge,Ou as StepTimings,lu as StepTreeMaster,Hx as StreamPanel,ha as Switch,Wa as SystemProvider,_d as TEXT_FIELD_LABEL,Od as TEXT_HINT,$d as TEXT_METRIC,Ld as TEXT_SECTION_LABEL,Bd as TEXT_VALUE,tu as Tabs,su as TabsContent,ru as TabsList,nu as TabsTrigger,Mr as ThemeProvider,Yd as Tooltip,Xd as TooltipContent,Jd as TooltipTrigger,bu as VersionBadge,Qx as WidgetRegistryProvider,Tl as WidgetSlot,i0 as ZoneEditingProvider,cu as buildStepTreeFromSchema,w as cn,Be as createSharedContext,Nd as createTheme,Vo as darkColors,Cr as defaultTheme,Eu as deriveDeviceKind,ca as ensureMfHostInit,Me as getClassColor,Fn as getPhaseVisual,cc as isFieldVisible,Ko as lightColors,qd as mirror,Gu as mountAddonPage,Vd as providerIcons,Kd as statusIcons,Cd as themeToCss,d as trpc,Wu as useAccessoriesGetStatus,Uu as useAddonPagesListPages,bp as useAddonSettingsGetDeviceSettings,fp as useAddonSettingsGetGlobalSettings,vp as useAddonSettingsUpdateDeviceSettings,hp as useAddonSettingsUpdateGlobalSettings,wl as useAddonWidgetsListWidgets,pp as useAddonsApplyAutoUpdateToAll,mp as useAddonsCustom,sp as useAddonsForceRefresh,dp as useAddonsGetAddonAutoUpdate,lp as useAddonsGetAutoUpdateSettings,qu as useAddonsGetLogs,ap as useAddonsGetVersions,Zu as useAddonsInstallFromWorkspace,Ku as useAddonsInstallPackage,Yu as useAddonsIsWorkspaceAvailable,Hu as useAddonsList,Vu as useAddonsListPackages,rp as useAddonsListUpdates,Ju as useAddonsListWorkspacePackages,gp as useAddonsOnAddonLogs,ep as useAddonsReloadPackages,ip as useAddonsRestartAddon,op as useAddonsRestartServer,tp as useAddonsSearchAvailable,up as useAddonsSetAddonAutoUpdate,cp as useAddonsSetAutoUpdateSettings,Xu as useAddonsUninstallPackage,np as useAddonsUpdatePackage,kp as useAlertsDismiss,xp as useAlertsEmit,Np as useAlertsGetUnreadCount,wp as useAlertsList,Sp as useAlertsMarkAllRead,Cp as useAlertsMarkRead,yp as useAlertsUpdate,Gx as useAllWidgets,Dp as useAudioAnalysisApplyDeviceSettingsPatch,Ap as useAudioAnalysisGetDeviceLiveContribution,Pp as useAudioAnalysisGetDeviceSettingsContribution,Mp as useAudioAnalysisResolveDeviceSettings,Ep as useAudioAnalyzerAnalyseChunk,Tp as useAudioAnalyzerClassify,Rp as useAudioAnalyzerDispose,Ip as useAudioAnalyzerIsReady,Lp as useAudioAnalyzerReprobeAudioEngine,Op as useAudioCodecCanHandle,Qp as useAudioCodecCloseSession,Bp as useAudioCodecCreateDecodeSession,$p as useAudioCodecCreateEncodeSession,Wp as useAudioCodecFlushEncode,Up as useAudioCodecListActiveSessions,_p as useAudioCodecListSupportedCodecs,zp as useAudioCodecPullEncoded,jp as useAudioCodecPullPcm,Gp as useAudioCodecPushEncodedFrame,Fp as useAudioCodecPushPcm,Hp as useAudioMetricsGetCurrentSnapshot,qp as useAudioMetricsGetHistory,Yp as useBackupDelete,Kp as useBackupList,Zp as useBackupRestore,Vp as useBackupTrigger,Jp as useBatteryGetStatus,em as useBrightnessGetStatus,Xp as useBrightnessSetBrightness,rm as useCameraStreamsGetBrokerStreams,tm as useCameraStreamsGetCameraStreams,nm as useCameraStreamsGetRtspEntries,ur as useClusterNodes,ps as useConfirm,xl as useCustomFieldRenderer,Bi as useDebouncedString,am as useDecoderCreateSession,im as useDecoderDestroySession,om as useDecoderGetInfo,pm as useDecoderGetStats,mm as useDecoderListActiveSessions,cm as useDecoderOpenStream,dm as useDecoderPullFrames,lm as useDecoderPushPacket,gm as useDecoderReprobeHwaccel,sm as useDecoderSupportsCodec,um as useDecoderUpdateConfig,bm as useDetectionPipelineApplyDeviceSettingsPatch,hm as useDetectionPipelineGetDeviceLiveContribution,fm as useDetectionPipelineGetDeviceSettingsContribution,Qu as useDevShell,g0 as useDevice,Di as useDeviceBattery,tt as useDeviceCapability,c0 as useDeviceDetections,ym as useDeviceDiscoveryAdoptDevice,Nm as useDeviceDiscoveryGetStatus,vm as useDeviceDiscoveryListDiscovered,xm as useDeviceDiscoveryRefreshDiscovery,wm as useDeviceDiscoveryReleaseDevice,yl as useDeviceId,Lm as useDeviceManagerAddLocation,lg as useDeviceManagerAdoptDevice,Cm as useDeviceManagerAllocateDeviceId,dg as useDeviceManagerCreateDevice,Hm as useDeviceManagerDisable,ig as useDeviceManagerDiscoverDevices,Um as useDeviceManagerEnable,Jm as useDeviceManagerGetAllBindings,Ym as useDeviceManagerGetBindings,Gm as useDeviceManagerGetChildren,Fm as useDeviceManagerGetConfigSchema,cg as useDeviceManagerGetCreationSchema,Qm as useDeviceManagerGetDevice,sg as useDeviceManagerGetDeviceAggregate,ng as useDeviceManagerGetDeviceLiveInfoAggregate,rg as useDeviceManagerGetDeviceSettingsAggregate,mg as useDeviceManagerGetDeviceStatusAggregate,zm as useDeviceManagerGetSettingsSchema,Vm as useDeviceManagerGetStreamProfileMap,jm as useDeviceManagerGetStreamSources,$m as useDeviceManagerListAll,tg as useDeviceManagerListBindableCapsForDeviceType,Rm as useDeviceManagerListLocations,Bm as useDeviceManagerListPersistedByAddon,eg as useDeviceManagerListWrappersForCap,Pm as useDeviceManagerLoadConfig,Dm as useDeviceManagerLoadMeta,Am as useDeviceManagerLoadRuntimeState,Mm as useDeviceManagerPersistConfig,Zm as useDeviceManagerProbeStreams,Sm as useDeviceManagerRegisterDevice,qm as useDeviceManagerRemove,km as useDeviceManagerRemoveDevice,_m as useDeviceManagerRemoveLocation,Om as useDeviceManagerSetDisabled,Tm as useDeviceManagerSetLocation,Im as useDeviceManagerSetMetadata,Em as useDeviceManagerSetName,Km as useDeviceManagerSetStreamProfileMap,Xm as useDeviceManagerSetWrapperActive,ug as useDeviceManagerTestCreationField,pg as useDeviceManagerTestField,Wm as useDeviceManagerUpdateConfig,og as useDeviceManagerUpdateDeviceField,ag as useDeviceManagerUpdateDeviceFieldsBatch,fg as useDeviceOpsGetConfigEntries,vg as useDeviceOpsGetSettingsSchema,gg as useDeviceOpsGetStreamSources,bg as useDeviceOpsRemoveDevice,hg as useDeviceOpsSetConfig,kg as useDeviceProviderAdoptDiscoveredDevice,Ag as useDeviceProviderCreateDevice,Sg as useDeviceProviderDiscoverDevices,Pg as useDeviceProviderGetChildCreationSchema,Ng as useDeviceProviderGetDevices,wg as useDeviceProviderGetStatus,xg as useDeviceProviderStart,yg as useDeviceProviderStop,Cg as useDeviceProviderSupportsDiscovery,Mg as useDeviceProviderSupportsManualCreation,Dg as useDeviceProviderTestCreationField,wt as useDeviceProxy,zu as useDeviceSnapshot,Ei as useDeviceSnapshotImage,ni as useDeviceState,Ig as useDeviceStateGetAllSnapshots,Tg as useDeviceStateGetCapSlice,Eg as useDeviceStateGetSnapshot,Rg as useDeviceStateSetCapSlice,ms as useDeviceStateSlice,d0 as useDeviceWebrtc,m0 as useDevices,p0 as useDoorbellEvents,Lg as useDoorbellGetStatus,b0 as useEventInvalidation,ds as useEventStreamLatest,mu as useEventStreamMap,Bg as useEventsGetEventClipUrl,Og as useEventsGetEventThumbnail,_g as useEventsGetEvents,jg as useIntegrationsCreate,zg as useIntegrationsDelete,Qg as useIntegrationsGet,Hg as useIntegrationsGetAvailableTypes,Gg as useIntegrationsGetByAddonId,Wg as useIntegrationsGetSettings,$g as useIntegrationsList,Ug as useIntegrationsSetSettings,qg as useIntegrationsTestConnection,Fg as useIntegrationsUpdate,Yg as useIntercomGetStatus,Kg as useIntercomHandleAnswer,Vg as useIntercomStartSession,Zg as useIntercomStopSession,eu as useIsMidWidth,et as useIsMobile,We as useLiveBuffer,yt as useLiveEvent,Jg as useMetricsProviderCollectSnapshot,af as useMetricsProviderGetAddonStats,Xg as useMetricsProviderGetCached,nf as useMetricsProviderGetCpuTemperature,ef as useMetricsProviderGetCurrent,tf as useMetricsProviderGetDiskSpace,rf as useMetricsProviderGetGpuInfo,sf as useMetricsProviderGetProcessStats,cf as useMetricsProviderKillProcess,of as useMetricsProviderListAddonInstances,lf as useMetricsProviderListNodeProcesses,pf as useMotionDetectionAnalyze,bf as useMotionDetectionApplyDeviceSettingsPatch,hf as useMotionDetectionGetDeviceLiveContribution,ff as useMotionDetectionGetDeviceSettingsContribution,mf as useMotionDetectionRemoveCamera,gf as useMotionDetectionReset,uf as useMotionGetStatus,df as useMotionIsDetected,xf as useMotionTriggerGetStatus,vf as useMotionTriggerSetMotionTrigger,yf as useNativeObjectDetectionGetStatus,Nf as useNetworkQualityGetAllStats,wf as useNetworkQualityGetDeviceStats,Cf as useNetworkQualityReportClientStats,If as useNodesClusterAddonStatus,kf as useNodesDeployAddon,Lf as useNodesExecuteQuery,Tf as useNodesRenameNode,Pf as useNodesRestartAddon,Df as useNodesRestartNode,Af as useNodesRestartProcess,Rf as useNodesSetProcessLogLevel,Ef as useNodesShutdownNode,Sf as useNodesTopology,Mf as useNodesUndeployAddon,_f as useNotificationOutputSend,Of as useNotificationOutputSendTest,pu as useOptionalSystem,Dl as useOptionalWidgetRegistry,$f as useOsdGetStatus,Bf as useOsdSetOverlay,u0 as usePTZ,Zf as usePipelineAnalyticsApplyDeviceSettingsPatch,Ff as usePipelineAnalyticsClearTracks,Qf as usePipelineAnalyticsGetActiveTracks,Uf as usePipelineAnalyticsGetAudioEvents,Kf as usePipelineAnalyticsGetDeviceLiveContribution,Vf as usePipelineAnalyticsGetDeviceSettingsContribution,Hf as usePipelineAnalyticsGetEventMedia,zf as usePipelineAnalyticsGetMotionEvents,Wf as usePipelineAnalyticsGetObjectEvents,Gf as usePipelineAnalyticsGetTrack,qf as usePipelineAnalyticsGetTrackMedia,jf as usePipelineAnalyticsListTracks,vh as usePipelineExecutorCacheFrameInPool,gh as usePipelineExecutorDeleteModel,dh as usePipelineExecutorDeleteTemplate,fh as usePipelineExecutorDetect,mh as usePipelineExecutorDownloadModel,ph as usePipelineExecutorGetAddonModels,Dh as usePipelineExecutorGetAudioCapabilities,Yf as usePipelineExecutorGetAvailableEngines,uh as usePipelineExecutorGetCapabilities,Xf as usePipelineExecutorGetDefaultSteps,Th as usePipelineExecutorGetDetectionConfigSchema,wh as usePipelineExecutorGetEffectiveTuning,oh as usePipelineExecutorGetGlobalPipelineConfig,sh as usePipelineExecutorGetGlobalSteps,ah as usePipelineExecutorGetOrchestratorConfigSchema,Ah as usePipelineExecutorGetReferenceAudio,Ph as usePipelineExecutorGetReferenceAudioFiles,Mh as usePipelineExecutorGetReferenceImage,nh as usePipelineExecutorGetSchema,Jf as usePipelineExecutorGetSelectedEngine,th as usePipelineExecutorGetVideoPipelineSteps,xh as usePipelineExecutorInferCached,Sh as usePipelineExecutorKillEngine,Nh as usePipelineExecutorListLoadedEngines,kh as usePipelineExecutorListReferenceImages,ih as usePipelineExecutorListTemplates,eh as usePipelineExecutorReprobeEngine,Eh as usePipelineExecutorRunAudioTest,hh as usePipelineExecutorRunPipeline,bh as usePipelineExecutorRunPipelineBatch,lh as usePipelineExecutorSaveTemplate,rh as usePipelineExecutorSetVideoPipelineSteps,Ch as usePipelineExecutorSpinEngine,yh as usePipelineExecutorUncacheFrame,ch as usePipelineExecutorUpdateTemplate,mb as usePipelineOrchestratorApplyDeviceSettingsPatch,Uh as usePipelineOrchestratorAssignAudio,Fh as usePipelineOrchestratorAssignDecoder,Ih as usePipelineOrchestratorAssignPipeline,db as usePipelineOrchestratorDeleteTemplate,Bh as usePipelineOrchestratorGetAgentLoad,Yh as usePipelineOrchestratorGetAgentSettings,qh as usePipelineOrchestratorGetAudioAssignment,Kh as usePipelineOrchestratorGetAudioAssignments,Vh as usePipelineOrchestratorGetAudioNodeLoad,Qh as usePipelineOrchestratorGetCameraMetrics,tb as usePipelineOrchestratorGetCameraSettings,nb as usePipelineOrchestratorGetCameraStepOverrides,Gh as usePipelineOrchestratorGetCapabilityBindings,Zh as usePipelineOrchestratorGetDecoderAssignment,Wh as usePipelineOrchestratorGetDecoderAssignments,pb as usePipelineOrchestratorGetDeviceLiveContribution,ub as usePipelineOrchestratorGetDeviceSettingsContribution,$h as usePipelineOrchestratorGetGlobalMetrics,Oh as usePipelineOrchestratorGetPipelineAssignment,_h as usePipelineOrchestratorGetPipelineAssignments,Jh as usePipelineOrchestratorListAgentSettings,ib as usePipelineOrchestratorListTemplates,Lh as usePipelineOrchestratorRebalance,eb as usePipelineOrchestratorRemoveAgentSettings,ab as usePipelineOrchestratorResolvePipeline,lb as usePipelineOrchestratorSaveTemplate,Xh as usePipelineOrchestratorSetAgentAddonDefaults,ob as usePipelineOrchestratorSetCameraPipelineForAgent,sb as usePipelineOrchestratorSetCameraStepOverride,rb as usePipelineOrchestratorSetCameraStepToggle,jh as usePipelineOrchestratorSetCapabilityBinding,Hh as usePipelineOrchestratorUnassignAudio,zh as usePipelineOrchestratorUnassignDecoder,Rh as usePipelineOrchestratorUnassignPipeline,cb as usePipelineOrchestratorUpdateTemplate,gb as usePipelineRunnerAttachCamera,fb as usePipelineRunnerDetachCamera,yb as usePipelineRunnerGetAllCameraMetrics,xb as usePipelineRunnerGetCameraMetrics,wb as usePipelineRunnerGetLocalCameras,bb as usePipelineRunnerGetLocalLoad,vb as usePipelineRunnerGetLocalMetrics,hb as usePipelineRunnerReportMotion,Nb as usePlatformProbeGetCapabilities,Cb as usePlatformProbeGetHardware,kb as usePlatformProbeResolveHwAccel,Sb as usePlatformProbeResolveInferenceConfig,Wx as usePlayerOverlayLayer,zx as usePlayerOverlayLayers,Ux as usePlayerToolbarButton,Sc as usePlayerToolbarButtons,Ob as usePtzAutotrackGetSettings,Lb as usePtzAutotrackGetStatus,_b as usePtzAutotrackSetEnabled,Bb as usePtzAutotrackSetSettings,Pb as usePtzContinuousMove,Ib as usePtzGetPosition,Db as usePtzGetPresets,Rb as usePtzGetStatus,Tb as usePtzGoHome,Eb as usePtzGoToPreset,Mb as usePtzMove,Ab as usePtzStop,$b as useRebootReboot,Wb as useRecordingEngineDisable,zb as useRecordingEngineEnable,Jb as useRecordingEngineEstimateGlobalStorage,Yb as useRecordingEngineEstimateStorage,Zb as useRecordingEngineGetAvailability,Ub as useRecordingEngineGetConfig,ov as useRecordingEngineGetMotionStats,qb as useRecordingEngineGetPlaylist,tv as useRecordingEngineGetPolicy,rv as useRecordingEngineGetPolicyStatus,nv as useRecordingEngineGetRetentionConfig,Kb as useRecordingEngineGetSegments,Fb as useRecordingEngineGetStatus,Xb as useRecordingEngineGetStorageUsage,Vb as useRecordingEngineGetThumbnail,ev as useRecordingEngineSetPolicy,Hb as useRecordingEngineUpdateConfig,sv as useRecordingEngineUpdateRetentionConfig,Gb as useRecordingGetPlaybackUrl,Qb as useRecordingGetSegments,jb as useRecordingGetThumbnailAt,pv as useSettingsStoreCount,gv as useSettingsStoreDeclareCollection,uv as useSettingsStoreDelete,av as useSettingsStoreGet,cv as useSettingsStoreInsert,mv as useSettingsStoreIsEmpty,lv as useSettingsStoreQuery,iv as useSettingsStoreSet,dv as useSettingsStoreUpdate,yv as useSnapshotApplyDeviceSettingsPatch,xv as useSnapshotGetDeviceLiveContribution,vv as useSnapshotGetDeviceSettingsContribution,fv as useSnapshotGetSnapshot,bv as useSnapshotGetStatus,hv as useSnapshotInvalidateCache,Nv as useSnapshotProviderGetSnapshot,wv as useSnapshotProviderSupportsDevice,Av as useStorageDelete,Mv as useStorageExists,Dv as useStorageGetAvailableSpace,Pv as useStorageList,kv as useStorageRead,Cv as useStorageResolve,Sv as useStorageWrite,Jv as useStreamBrokerApplyDeviceSettingsPatch,Iv as useStreamBrokerAssignProfile,Uv as useStreamBrokerGetAllRtspEntries,jv as useStreamBrokerGetBroker,Ov as useStreamBrokerGetBrokerStats,Yv as useStreamBrokerGetDeviceLiveContribution,Zv as useStreamBrokerGetDeviceSettingsContribution,zv as useStreamBrokerGetPreBufferInfo,Hv as useStreamBrokerGetRtspEntry,Wv as useStreamBrokerGetRtspPort,Gv as useStreamBrokerGetStreamUrl,Kv as useStreamBrokerIsRtspEnabled,$v as useStreamBrokerKillClient,Lv as useStreamBrokerListAllCameraStreams,_v as useStreamBrokerListAllProfileSlots,Bv as useStreamBrokerListClients,Ev as useStreamBrokerPublishCameraStream,qv as useStreamBrokerRegenerateRtspToken,Qv as useStreamBrokerRestartProfile,Tv as useStreamBrokerRetractCameraStream,Fv as useStreamBrokerSetPreBufferDuration,Vv as useStreamBrokerSetRtspEnabled,Rv as useStreamBrokerUnassignProfile,ex as useSwitchGetStatus,Xv as useSwitchSetState,He as useSystem,nx as useSystemFeatureFlags,ix as useSystemForceRetentionCleanup,ox as useSystemGetRetentionConfig,rx as useSystemHealth,tx as useSystemInfo,h0 as useSystemMutation,sx as useSystemNetworkAddresses,f0 as useSystemQuery,ax as useSystemSetRetentionConfig,ta as useThemeMode,lx as useToastOnToast,cx as useTurnProviderGetTurnServers,bx as useUserManagementCreateApiKey,yx as useUserManagementCreateScopedToken,ux as useUserManagementCreateUser,mx as useUserManagementDeleteUser,hx as useUserManagementListApiKeys,Cx as useUserManagementListScopedTokens,dx as useUserManagementListUsers,gx as useUserManagementResetPassword,vx as useUserManagementRevokeApiKey,wx as useUserManagementRevokeScopedToken,px as useUserManagementUpdateUser,xx as useUserManagementValidateApiKey,fx as useUserManagementValidateCredentials,Nx as useUserManagementValidateScopedToken,Px as useWebrtcSessionCloseSession,kx as useWebrtcSessionCreateSession,Mx as useWebrtcSessionHandleAnswer,Ax as useWebrtcSessionHasAdaptiveBitrate,Sx as useWebrtcSessionListStreams,Pl as useWidget,Al as useWidgetMetadata,mr as useWidgetRegistry,Tx as useZoneAnalyticsGetCameraHistory,Dx as useZoneAnalyticsGetCurrentSnapshot,Ix as useZoneAnalyticsGetUnzonedHistory,Ex as useZoneAnalyticsGetZoneHistory,l0 as useZoneEditing,Rx as useZoneRulesListRules,Lx as useZoneRulesSetRules,Ox as useZonesAddZone,_x as useZonesListZones,Bx as useZonesRemoveZone,$x as useZonesUpdateZone};
|