@camstack/addon-admin-ui 0.1.36 → 0.1.37
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-CeLhKMin.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-Cv6qLu_-.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-DXPQtD9p.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-CChEG9e0.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-OcRSBqRe.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-C1BmHlGM.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-GvBGLFI2.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-Bxv_3KWz.js} +1 -1
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs-g85Oidc0.js +15 -0
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs_commonjs-proxy-Bqeq2Zwj.js +1 -0
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-Dl4u0xYE.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-DC63qZbr.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-CSyOECfO.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-D2C49VyZ.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-CzO_Esxm.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-D3WbXy3O.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-xw6c6JeS.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Csg6EbPB.js} +1 -1
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-DNpf5SLz.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CUc0oFNo.js} +2 -2
- package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-BEKtiDI3.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-vh0hhA5d.js} +1 -1
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-CpGtTxci.js +35 -0
- package/dist/assets/__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs_commonjs-proxy-RUDPE9aM.js +1 -0
- package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cjyt3AKP.js +1 -0
- package/dist/assets/{devices-D4k34mru.js → devices-GLp7me2a.js} +1 -1
- package/dist/assets/hostInit-Cx72YpvD.js +1 -0
- package/dist/assets/index-ByRJWRUP.js +1 -0
- package/dist/assets/index-COoei6lw.css +1 -0
- package/dist/assets/index-CtHpLu0L.js +1 -0
- package/dist/assets/{index-D92THlot.js → index-CwF7Dxf8.js} +1 -1
- package/dist/assets/{index-BI3Z7SSi.js → index-D6khiudP.js} +1 -1
- package/dist/assets/index-DNY_otk4.js +151 -0
- package/dist/assets/index-DQFO9ZU6.js +1 -0
- package/dist/assets/index-G9qsQFtk.js +1150 -0
- package/dist/assets/{index-BGZqVJZt.js → index-JJ5NLHxC.js} +1 -1
- package/dist/assets/{index-Bwcmc2hW.js → index-TiJwCuZx.js} +1 -1
- package/dist/assets/index-WrAHDGEr.js +87 -0
- package/dist/assets/index-b0D9qthW.js +1 -0
- package/dist/assets/method-access-map-DLEhlu0x.js +1 -0
- package/dist/assets/{remoteEntry-BRybuw2S.js → remoteEntry-CbhqJYoN.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DUkp33c_.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-I5siGnQL.js} +6 -6
- package/dist/index.html +6 -6
- package/dist/mf-entry-bootstrap-0.js +2 -2
- package/dist/server/addon.js +528 -96
- package/dist/server/addon.js.map +1 -1
- package/dist/sw.js +1 -1
- package/package.json +10 -2
- package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DYU-qDnu.js +0 -1
- package/dist/assets/hostInit-CBKchP1G.js +0 -1
- package/dist/assets/index-BEewR-UX.js +0 -1
- package/dist/assets/index-BRSAFSOw.css +0 -1
- package/dist/assets/index-BqMPfvQx.js +0 -1
- package/dist/assets/index-CP1R6E2R.js +0 -88
- package/dist/assets/index-CwjnPcOV.js +0 -152
- package/dist/assets/index-Dmon2mdO.js +0 -1
- package/dist/assets/index-KlKJOjpC.js +0 -1
- package/dist/assets/index-SyrojlmO.js +0 -1156
- package/dist/assets/method-access-map-BFPyQ2-G.js +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import{e as E,h as R,c as Q,f as q,d as Re,b as Je,i as W,n as De,R as Me,m as bt,o as $l,k as Kt,g as jn,a as _s}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-DC63qZbr.js";import{c as o,d as m,e as we,a as Is}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as Lr,a as Ts}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-D3WbXy3O.js";import{b as Bl,a as Ds}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CUc0oFNo.js";import{n as or,m as Ls,h as zl,o as Fl,p as Gl,_ as Os}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-Cv6qLu_-.js";import{c as $s,s as Bs,B as Ql,F as jl,n as Ul,_ as zs}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{a as Hl,_ as Fs}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-C1BmHlGM.js";import{_ as Gs}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-CpGtTxci.js";import{_ as Qs}from"./__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs-g85Oidc0.js";import{K as Vl,E as Y,A as ql}from"./method-access-map-DLEhlu0x.js";import{D as Wl,c as Kl,E as Zl}from"./index-DQFO9ZU6.js";import{c as Yl}from"./devices-GLp7me2a.js";import{a as Xl}from"./schemas-BEt-CulV.js";import"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-D2C49VyZ.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Csg6EbPB.js";var js={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},Jl={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:js},ec={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:js},ho={colors:{dark:Jl,light:ec},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 Us(e,t){const r={...e};for(const n in t){const s=t[n],a=e[n];s!==void 0&&typeof s=="object"&&s!==null&&!Array.isArray(s)&&typeof a=="object"&&a!==null?r[n]=Us(a,s):s!==void 0&&(r[n]=s)}return r}function yv(e){return e?Us(structuredClone(ho),e):structuredClone(ho)}function Hs(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function tc(e){return`--color-${Hs(e)}`}function go(e){const t=[];for(const[r,n]of Object.entries(e))r!=="provider"&&t.push(` ${tc(r)}: ${n};`);return t.join(`
|
|
2
|
+
`)}function rc(e){const t=[];for(const[r,n]of Object.entries(e))t.push(` --color-provider-${Hs(r)}: ${n};`);return t.join(`
|
|
3
|
+
`)}function nc(e){const t=[];for(const[r,n]of Object.entries(e))t.push(` --spacing-${r}: ${n}px;`);return t.join(`
|
|
4
|
+
`)}function oc(e){const t=[];for(const[r,n]of Object.entries(e))t.push(` --radius-${r}: ${n}px;`);return t.join(`
|
|
5
|
+
`)}function xv(e){const t=go(e.colors.dark),r=go(e.colors.light);return`@theme {
|
|
6
|
+
${rc(e.colors.dark.provider)}
|
|
7
|
+
${nc(e.spacing)}
|
|
8
|
+
${oc(e.radius)}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dark {
|
|
12
|
+
${t}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.light {
|
|
16
|
+
${r}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
:root {
|
|
21
|
+
${t.replace(/^ {2}/gm," ")}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (prefers-color-scheme: light) {
|
|
26
|
+
:root {
|
|
27
|
+
${r.replace(/^ {2}/gm," ")}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`}var Vs=Je(null),Hr=["dark","light","system"];function qs(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function sc(e,t){if(typeof window>"u")return t;const r=localStorage.getItem(e);return r==="dark"||r==="light"||r==="system"?r:t}function bo(e){return e==="system"?qs():e}function vo({children:e,defaultMode:t="system",storageKey:r="camstack-theme-mode"}){const[n,s]=E(()=>sc(r,t)),[a,i]=E(()=>bo(n)),c=R(d=>{s(d),i(bo(d)),typeof window<"u"&&localStorage.setItem(r,d)},[r]),l=R(()=>{c(Hr[(Hr.indexOf(n)+1)%Hr.length]??"dark")},[n,c]);Q(()=>{if(typeof document>"u")return;const d=document.documentElement;d.classList.remove("dark","light"),d.classList.add(a)},[n,a]),Q(()=>{if(typeof window>"u"||n!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(qs())};return d.addEventListener("change",p),()=>d.removeEventListener("change",p)},[n]);const u=q(()=>({mode:n,resolvedMode:a,setMode:c,toggleMode:l}),[n,a,c,l]);return o(Vs.Provider,{value:u,children:e})}function ac(){const e=Re(Vs);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}var Vr={};function Ws(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(r=Ws(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Ks(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=Ws(e))&&(n&&(n+=" "),n+=t);return n}var ic=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},lc=(e,t)=>({classGroupId:e,validator:t}),Zs=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Ar="-",yo=[],cc="arbitrary..",uc=e=>{const t=pc(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return dc(i);const c=i.split(Ar);return Ys(c,c[0]===""&&c.length>1?1:0,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=n[i],u=r[i];return l?u?ic(u,l):l:u||yo}return r[i]||yo}}},Ys=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],s=r.nextPart.get(n);if(s){const l=Ys(e,t+1,s);if(l)return l}const a=r.validators;if(a===null)return;const i=t===0?e.join(Ar):e.slice(t).join(Ar),c=a.length;for(let l=0;l<c;l++){const u=a[l];if(u.validator(i))return u.classGroupId}},dc=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?cc+n:void 0})(),pc=e=>{const{theme:t,classGroups:r}=e;return fc(r,t)},fc=(e,t)=>{const r=Zs();for(const n in e){const s=e[n];Un(s,r,n,t)}return r},Un=(e,t,r,n)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];mc(i,t,r,n)}},mc=(e,t,r,n)=>{if(typeof e=="string"){hc(e,t,r);return}if(typeof e=="function"){gc(e,t,r,n);return}bc(e,t,r,n)},hc=(e,t,r)=>{const n=e===""?t:Xs(t,e);n.classGroupId=r},gc=(e,t,r,n)=>{if(vc(e)){Un(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(lc(r,e))},bc=(e,t,r,n)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[c,l]=s[i];Un(l,Xs(t,c),r,n)}},Xs=(e,t)=>{let r=e;const n=t.split(Ar),s=n.length;for(let a=0;a<s;a++){const i=n[a];let c=r.nextPart.get(i);c||(c=Zs(),r.nextPart.set(i,c)),r=c}return r},vc=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,yc=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const s=(a,i)=>{r[a]=i,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(a){let i=r[a];if(i!==void 0)return i;if((i=n[a])!==void 0)return s(a,i),i},set(a,i){a in r?r[a]=i:s(a,i)}}},hn="!",xo=":",xc=[],wo=(e,t,r,n,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:s}),wc=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=s=>{const a=[];let i=0,c=0,l=0,u;const d=s.length;for(let v=0;v<d;v++){const y=s[v];if(i===0&&c===0){if(y===xo){a.push(s.slice(l,v)),l=v+1;continue}if(y==="/"){u=v;continue}}y==="["?i++:y==="]"?i--:y==="("?c++:y===")"&&c--}const p=a.length===0?s:s.slice(l);let h=p,g=!1;p.endsWith(hn)?(h=p.slice(0,-1),g=!0):p.startsWith(hn)&&(h=p.slice(1),g=!0);const b=u&&u>l?u-l:void 0;return wo(a,g,h,b)};if(t){const s=t+xo,a=n;n=i=>i.startsWith(s)?a(i.slice(s.length)):wo(xc,!1,i,void 0,!0)}if(r){const s=n;n=a=>r({className:a,parseClassName:s})}return n},kc=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let s=[];for(let a=0;a<r.length;a++){const i=r[a],c=i[0]==="[",l=t.has(i);c||l?(s.length>0&&(s.sort(),n.push(...s),s=[]),n.push(i)):s.push(i)}return s.length>0&&(s.sort(),n.push(...s)),n}},Nc=e=>({cache:yc(e.cacheSize),parseClassName:wc(e),sortModifiers:kc(e),...uc(e)}),Sc=/\s+/,Cc=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],c=e.trim().split(Sc);let l="";for(let u=c.length-1;u>=0;u-=1){const d=c[u],{isExternal:p,modifiers:h,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:v}=r(d);if(p){l=d+(l.length>0?" "+l:l);continue}let y=!!v,x=n(y?b.substring(0,v):b);if(!x){if(!y){l=d+(l.length>0?" "+l:l);continue}if(x=n(b),!x){l=d+(l.length>0?" "+l:l);continue}y=!1}const k=h.length===0?"":h.length===1?h[0]:a(h).join(":"),w=g?k+hn:k,N=w+x;if(i.indexOf(N)>-1)continue;i.push(N);const S=s(x,y);for(let M=0;M<S.length;++M){const P=S[M];i.push(w+P)}l=d+(l.length>0?" "+l:l)}return l},Mc=(...e)=>{let t=0,r,n,s="";for(;t<e.length;)(r=e[t++])&&(n=Js(r))&&(s&&(s+=" "),s+=n);return s},Js=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Js(e[n]))&&(r&&(r+=" "),r+=t);return r},Ec=(e,...t)=>{let r,n,s,a;const i=l=>(r=Nc(t.reduce((u,d)=>d(u),e())),n=r.cache.get,s=r.cache.set,a=c,c(l)),c=l=>{const u=n(l);if(u)return u;const d=Cc(l,r);return s(l,d),d};return a=i,(...l)=>a(Mc(...l))},Ac=[],Pe=e=>{const t=r=>r[e]||Ac;return t.isThemeGetter=!0,t},ea=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ta=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Pc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Rc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_c=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ic=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Tc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Dc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,rt=e=>Pc.test(e),ce=e=>!!e&&!Number.isNaN(Number(e)),nt=e=>!!e&&Number.isInteger(Number(e)),qr=e=>e.endsWith("%")&&ce(e.slice(0,-1)),Xe=e=>Rc.test(e),ra=()=>!0,Lc=e=>_c.test(e)&&!Ic.test(e),Hn=()=>!1,Oc=e=>Tc.test(e),$c=e=>Dc.test(e),Bc=e=>!j(e)&&!U(e),zc=e=>lt(e,sa,Hn),j=e=>ea.test(e),ft=e=>lt(e,aa,Lc),ko=e=>lt(e,qc,ce),Fc=e=>lt(e,la,ra),Gc=e=>lt(e,ia,Hn),No=e=>lt(e,na,Hn),Qc=e=>lt(e,oa,$c),lr=e=>lt(e,ca,Oc),U=e=>ta.test(e),Qt=e=>yt(e,aa),jc=e=>yt(e,ia),So=e=>yt(e,na),Uc=e=>yt(e,sa),Hc=e=>yt(e,oa),cr=e=>yt(e,ca,!0),Vc=e=>yt(e,la,!0),lt=(e,t,r)=>{const n=ea.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},yt=(e,t,r=!1)=>{const n=ta.exec(e);return n?n[1]?t(n[1]):r:!1},na=e=>e==="position"||e==="percentage",oa=e=>e==="image"||e==="url",sa=e=>e==="length"||e==="size"||e==="bg-size",aa=e=>e==="length",qc=e=>e==="number",ia=e=>e==="family-name",la=e=>e==="number"||e==="weight",ca=e=>e==="shadow",Wc=()=>{const e=Pe("color"),t=Pe("font"),r=Pe("text"),n=Pe("font-weight"),s=Pe("tracking"),a=Pe("leading"),i=Pe("breakpoint"),c=Pe("container"),l=Pe("spacing"),u=Pe("radius"),d=Pe("shadow"),p=Pe("inset-shadow"),h=Pe("text-shadow"),g=Pe("drop-shadow"),b=Pe("blur"),v=Pe("perspective"),y=Pe("aspect"),x=Pe("ease"),k=Pe("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...N(),U,j],M=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],A=()=>[U,j,l],V=()=>[rt,"full","auto",...A()],H=()=>[nt,"none","subgrid",U,j],ae=()=>["auto",{span:["full",nt,U,j]},nt,U,j],pe=()=>[nt,"auto",U,j],ne=()=>["auto","min","max","fr",U,j],se=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],oe=()=>["start","end","center","stretch","center-safe","end-safe"],J=()=>["auto",...A()],K=()=>[rt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],fe=()=>[rt,"screen","full","dvw","lvw","svw","min","max","fit",...A()],Z=()=>[rt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...A()],D=()=>[e,U,j],F=()=>[...N(),So,No,{position:[U,j]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ie=()=>["auto","cover","contain",Uc,zc,{size:[U,j]}],_=()=>[qr,Qt,ft],L=()=>["","none","full",u,U,j],G=()=>["",ce,Qt,ft],B=()=>["solid","dashed","dotted","double"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>[ce,qr,So,No],Le=()=>["","none",b,U,j],Oe=()=>["none",ce,U,j],ee=()=>["none",ce,U,j],he=()=>[ce,U,j],ke=()=>[rt,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xe],breakpoint:[Xe],color:[ra],container:[Xe],"drop-shadow":[Xe],ease:["in","out","in-out"],font:[Bc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xe],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xe],shadow:[Xe],spacing:["px",ce],text:[Xe],"text-shadow":[Xe],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",rt,j,U,y]}],container:["container"],columns:[{columns:[ce,j,U,c]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:V()}],"inset-x":[{"inset-x":V()}],"inset-y":[{"inset-y":V()}],start:[{"inset-s":V(),start:V()}],end:[{"inset-e":V(),end:V()}],"inset-bs":[{"inset-bs":V()}],"inset-be":[{"inset-be":V()}],top:[{top:V()}],right:[{right:V()}],bottom:[{bottom:V()}],left:[{left:V()}],visibility:["visible","invisible","collapse"],z:[{z:[nt,"auto",U,j]}],basis:[{basis:[rt,"full","auto",c,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ce,rt,"auto","initial","none",j]}],grow:[{grow:["",ce,U,j]}],shrink:[{shrink:["",ce,U,j]}],order:[{order:[nt,"first","last","none",U,j]}],"grid-cols":[{"grid-cols":H()}],"col-start-end":[{col:ae()}],"col-start":[{"col-start":pe()}],"col-end":[{"col-end":pe()}],"grid-rows":[{"grid-rows":H()}],"row-start-end":[{row:ae()}],"row-start":[{"row-start":pe()}],"row-end":[{"row-end":pe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...se(),"normal"]}],"justify-items":[{"justify-items":[...oe(),"normal"]}],"justify-self":[{"justify-self":["auto",...oe()]}],"align-content":[{content:["normal",...se()]}],"align-items":[{items:[...oe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...oe(),{baseline:["","last"]}]}],"place-content":[{"place-content":se()}],"place-items":[{"place-items":[...oe(),"baseline"]}],"place-self":[{"place-self":["auto",...oe()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pbs:[{pbs:A()}],pbe:[{pbe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:J()}],mx:[{mx:J()}],my:[{my:J()}],ms:[{ms:J()}],me:[{me:J()}],mbs:[{mbs:J()}],mbe:[{mbe:J()}],mt:[{mt:J()}],mr:[{mr:J()}],mb:[{mb:J()}],ml:[{ml:J()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],"inline-size":[{inline:["auto",...fe()]}],"min-inline-size":[{"min-inline":["auto",...fe()]}],"max-inline-size":[{"max-inline":["none",...fe()]}],"block-size":[{block:["auto",...Z()]}],"min-block-size":[{"min-block":["auto",...Z()]}],"max-block-size":[{"max-block":["none",...Z()]}],w:[{w:[c,"screen",...K()]}],"min-w":[{"min-w":[c,"screen","none",...K()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",r,Qt,ft]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Vc,Fc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",qr,j]}],"font-family":[{font:[jc,Gc,t]}],"font-features":[{"font-features":[j]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,U,j]}],"line-clamp":[{"line-clamp":[ce,"none",U,ko]}],leading:[{leading:[a,...A()]}],"list-image":[{"list-image":["none",U,j]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",U,j]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:[ce,"from-font","auto",U,ft]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[ce,"auto",U,j]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",U,j]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",U,j]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:ie()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},nt,U,j],radial:["",U,j],conic:[nt,U,j]},Hc,Qc]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:_()}],"gradient-via-pos":[{via:_()}],"gradient-to-pos":[{to:_()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:L()}],"rounded-s":[{"rounded-s":L()}],"rounded-e":[{"rounded-e":L()}],"rounded-t":[{"rounded-t":L()}],"rounded-r":[{"rounded-r":L()}],"rounded-b":[{"rounded-b":L()}],"rounded-l":[{"rounded-l":L()}],"rounded-ss":[{"rounded-ss":L()}],"rounded-se":[{"rounded-se":L()}],"rounded-ee":[{"rounded-ee":L()}],"rounded-es":[{"rounded-es":L()}],"rounded-tl":[{"rounded-tl":L()}],"rounded-tr":[{"rounded-tr":L()}],"rounded-br":[{"rounded-br":L()}],"rounded-bl":[{"rounded-bl":L()}],"border-w":[{border:G()}],"border-w-x":[{"border-x":G()}],"border-w-y":[{"border-y":G()}],"border-w-s":[{"border-s":G()}],"border-w-e":[{"border-e":G()}],"border-w-bs":[{"border-bs":G()}],"border-w-be":[{"border-be":G()}],"border-w-t":[{"border-t":G()}],"border-w-r":[{"border-r":G()}],"border-w-b":[{"border-b":G()}],"border-w-l":[{"border-l":G()}],"divide-x":[{"divide-x":G()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":G()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...B(),"hidden","none"]}],"divide-style":[{divide:[...B(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...B(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ce,U,j]}],"outline-w":[{outline:["",ce,Qt,ft]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",d,cr,lr]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",p,cr,lr]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[ce,ft]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":G()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",h,cr,lr]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[ce,U,j]}],"mix-blend":[{"mix-blend":[...te(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":te()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ce]}],"mask-image-linear-from-pos":[{"mask-linear-from":X()}],"mask-image-linear-to-pos":[{"mask-linear-to":X()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":X()}],"mask-image-t-to-pos":[{"mask-t-to":X()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":X()}],"mask-image-r-to-pos":[{"mask-r-to":X()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":X()}],"mask-image-b-to-pos":[{"mask-b-to":X()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":X()}],"mask-image-l-to-pos":[{"mask-l-to":X()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":X()}],"mask-image-x-to-pos":[{"mask-x-to":X()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":X()}],"mask-image-y-to-pos":[{"mask-y-to":X()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[U,j]}],"mask-image-radial-from-pos":[{"mask-radial-from":X()}],"mask-image-radial-to-pos":[{"mask-radial-to":X()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[ce]}],"mask-image-conic-from-pos":[{"mask-conic-from":X()}],"mask-image-conic-to-pos":[{"mask-conic-to":X()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:ie()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",U,j]}],filter:[{filter:["","none",U,j]}],blur:[{blur:Le()}],brightness:[{brightness:[ce,U,j]}],contrast:[{contrast:[ce,U,j]}],"drop-shadow":[{"drop-shadow":["","none",g,cr,lr]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",ce,U,j]}],"hue-rotate":[{"hue-rotate":[ce,U,j]}],invert:[{invert:["",ce,U,j]}],saturate:[{saturate:[ce,U,j]}],sepia:[{sepia:["",ce,U,j]}],"backdrop-filter":[{"backdrop-filter":["","none",U,j]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[ce,U,j]}],"backdrop-contrast":[{"backdrop-contrast":[ce,U,j]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ce,U,j]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ce,U,j]}],"backdrop-invert":[{"backdrop-invert":["",ce,U,j]}],"backdrop-opacity":[{"backdrop-opacity":[ce,U,j]}],"backdrop-saturate":[{"backdrop-saturate":[ce,U,j]}],"backdrop-sepia":[{"backdrop-sepia":["",ce,U,j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",U,j]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ce,"initial",U,j]}],ease:[{ease:["linear","initial",x,U,j]}],delay:[{delay:[ce,U,j]}],animate:[{animate:["none",k,U,j]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,U,j]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:Oe()}],"rotate-x":[{"rotate-x":Oe()}],"rotate-y":[{"rotate-y":Oe()}],"rotate-z":[{"rotate-z":Oe()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":["scale-3d"],skew:[{skew:he()}],"skew-x":[{"skew-x":he()}],"skew-y":[{"skew-y":he()}],transform:[{transform:[U,j,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ke()}],"translate-x":[{"translate-x":ke()}],"translate-y":[{"translate-y":ke()}],"translate-z":[{"translate-z":ke()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",U,j]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mbs":[{"scroll-mbs":A()}],"scroll-mbe":[{"scroll-mbe":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pbs":[{"scroll-pbs":A()}],"scroll-pbe":[{"scroll-pbe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",U,j]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[ce,Qt,ft,ko]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Kc=Ec(Wc);function C(...e){return Kc(Ks(e))}var wv="rounded-lg border border-border bg-surface overflow-hidden",kv="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",Nv="p-2 sm:p-3 lg:p-4",Sv="space-y-3 sm:space-y-4",Cv="gap-2 sm:gap-3",Mv="px-3 sm:px-4 py-1.5 sm:py-2",Ev="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",Av="grid grid-cols-1 lg:grid-cols-2",Pv="flex flex-col-reverse md:flex-row",Rv="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",_v="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",Iv="text-[11px] sm:text-xs text-foreground",ur="text-[10px] text-foreground-subtle",Tv="text-[11px] sm:text-xs font-medium text-foreground",Dv="text-base sm:text-lg font-semibold leading-tight text-foreground",Lv="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",Ov="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",$v="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",Bv="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",zv="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",Fv="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",Gv="border-primary/50 bg-primary/15 text-primary",Qv="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function Zc(e,t){for(const r of e.slots)for(const n of r.addons)if(n.id===t)return n;return null}function Yc(e,t){return e.models.find(r=>r.id===t)??null}function Xc(e,t){return e.models.find(r=>!!r.formats[t])??null}function Jc(e,t){const r=new Set((t.configSchema??[]).map(s=>s.key)),n={};for(const[s,a]of Object.entries(e))r.has(s)&&(n[s]=a);return n}function jv(e){const{source:t,target:r,catalog:n,addonIds:s}=e,a=[];for(const i of s){const c=t.defaults[i];if(!c){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no source entry",patch:null});continue}const l=Zc(n,i);if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const u=Yc(l,c.modelId),d=u!==null&&!!u.formats[r.engine.format];let p,h;if(d)p=c.modelId,h="exact";else{const b=Xc(l,r.engine.format);if(!b){a.push({addonId:i,outcome:"skip",modelId:null,reason:"no compatible model for target format",patch:null});continue}p=b.id,h="mapped"}const g={enabled:c.enabled,modelId:p,settings:Jc(c.settings,l)};a.push({addonId:i,outcome:h,modelId:p,patch:g})}return a}var Co={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 ua(e){return Co[e]??Co.watching}function ct(e,t){if(typeof globalThis>"u")return Je(t);const r=globalThis.__camstackSharedContexts,n=r??new Map;r||(globalThis.__camstackSharedContexts=n);const s=n.get(e);if(s)return s;const a=Je(t);return n.set(e,a),a}var eu="FEDERATION_DEBUG",gn=(function(e){return e[e.UNKNOWN=1]="UNKNOWN",e[e.CALCULATED=2]="CALCULATED",e[e.NO_USE=0]="NO_USE",e})({}),da=!0;function tu(){return da}function ru(){try{if(tu()&&window.localStorage)return!!localStorage.getItem(eu)}catch{return!1}return!1}function bn(){return typeof process<"u"&&Vr&&Vr.FEDERATION_DEBUG?!!Vr.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:ru()}var nu="[ Federation Runtime ]",pa=function(...e){return e.length?e.reduce((t,r)=>r?t?`${t}:${r}`:r:t,""):""},vn=(e,t)=>{if("getPublicPath"in e){let r;return e.getPublicPath.startsWith("function")?r=new Function("return "+e.getPublicPath)()():r=new Function(e.getPublicPath)(),`${r}${t}`}else return"publicPath"in e?`${e.publicPath}${t}`:(console.warn("Cannot get resource URL. If in debug mode, please ignore.",e,t),"")},fa=e=>{console.warn(`${nu}: ${e}`)};function ma(e){try{return JSON.stringify(e,null,2)}catch{return""}}var Wr=(e,t)=>{if(!e)return t;const n=(s=>{if(s===".")return"";if(s.startsWith("./"))return s.replace("./","");if(s.startsWith("/")){const a=s.slice(1);return a.endsWith("/")?a.slice(0,-1):a}return s})(e);return n?n.endsWith("/")?`${n}${t}`:`${n}/${t}`:t};function ou(e){return e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function su(e,t={}){const{remotes:r={},overrides:n={},version:s}=t;let a;const i=()=>"publicPath"in e.metaData?(e.metaData.publicPath==="auto"||e.metaData.publicPath==="")&&s?ou(s):e.metaData.publicPath:e.metaData.getPublicPath,c=Object.keys(n);let l={};Object.keys(r).length||(l=e.remotes?.reduce((k,w)=>{let N;const S=w.federationContainerName;return c.includes(S)?N=n[S]:"version"in w?N=w.version:N=w.entry,k[S]={matchedVersion:N},k},{})||{}),Object.keys(r).forEach(k=>l[k]={matchedVersion:c.includes(k)?n[k]:r[k]});const{remoteEntry:{path:u,name:d,type:p},types:h={path:"",name:"",zip:"",api:""},buildInfo:{buildVersion:g},globalName:b,ssrRemoteEntry:v}=e.metaData,{exposes:y}=e;let x={version:s||"",buildVersion:g,globalName:b,remoteEntry:Wr(u,d),remoteEntryType:p,remoteTypes:Wr(h.path,h.name),remoteTypesZip:h.zip||"",remoteTypesAPI:h.api||"",remotesInfo:l,shared:e?.shared.map(k=>({assets:k.assets,sharedName:k.name,version:k.version,usedExports:k.referenceExports||[]})),modules:y?.map(k=>({moduleName:k.name,modulePath:k.path,assets:k.assets}))};if("publicPath"in e.metaData?(a={...x,publicPath:i()},typeof e.metaData.ssrPublicPath=="string"&&(a.ssrPublicPath=e.metaData.ssrPublicPath)):a={...x,getPublicPath:i()},v){const k=Wr(v.path,v.name);a.ssrRemoteEntry=k,a.ssrRemoteEntryType=v.type||"commonjs-module"}return a}function ha(e){return!!("remoteEntry"in e&&e.remoteEntry.includes(".json"))}var au="[ Module Federation ]",jt=console,iu=["logger.ts","logger.js","captureStackTrace","Logger.emit","Logger.log","Logger.info","Logger.warn","Logger.error","Logger.debug"];function lu(){try{const e=new Error().stack;if(!e)return;const[,...t]=e.split(`
|
|
31
|
+
`),r=t.filter(n=>!iu.some(s=>n.includes(s)));return r.length?`Stack trace:
|
|
32
|
+
${r.slice(0,5).join(`
|
|
33
|
+
`)}`:void 0}catch{return}}var ga=class{constructor(e,t=jt){this.prefix=e,this.delegate=t??jt}setPrefix(e){this.prefix=e}setDelegate(e){this.delegate=e??jt}emit(e,t){const r=this.delegate,n=bn()?lu():void 0,s=n?[...t,n]:t,a=(()=>{switch(e){case"log":return["log","info"];case"info":return["info","log"];case"warn":return["warn","info","log"];case"error":return["error","warn","log"];default:return["debug","log"]}})();for(const i of a){const c=r[i];if(typeof c=="function"){c.call(r,this.prefix,...s);return}}for(const i of a){const c=jt[i];if(typeof c=="function"){c.call(jt,this.prefix,...s);return}}}log(...e){this.emit("log",e)}warn(...e){this.emit("warn",e)}error(...e){this.emit("error",e)}success(...e){this.emit("info",e)}info(...e){this.emit("info",e)}ready(...e){this.emit("info",e)}debug(...e){bn()&&this.emit("debug",e)}};function cu(e){return new ga(e)}function uu(e){const t=new ga(e);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}uu(au);async function ba(e,t){try{return await e()}catch(r){fa(r);return}}function yn(e,t){const r=/^(https?:)?\/\//i;return e.replace(r,"").replace(/\/$/,"")===t.replace(r,"").replace(/\/$/,"")}function va(e){let t=null,r=!0,n=2e4,s;const a=document.getElementsByTagName("script");for(let u=0;u<a.length;u++){const d=a[u],p=d.getAttribute("src");if(p&&yn(p,e.url)){t=d,r=!1;break}}if(!t){const u=e.attrs;t=document.createElement("script"),t.type=u?.type==="module"?"module":"text/javascript";let d;e.createScriptHook&&(d=e.createScriptHook(e.url,e.attrs),d instanceof HTMLScriptElement?t=d:typeof d=="object"&&("script"in d&&d.script&&(t=d.script),"timeout"in d&&d.timeout&&(n=d.timeout))),t.src||(t.src=e.url),u&&!d&&Object.keys(u).forEach(p=>{t&&(p==="async"||p==="defer"?t[p]=u[p]:t.getAttribute(p)||t.setAttribute(p,u[p]))})}let i=null;const c=typeof window<"u"?u=>{if(u.filename&&yn(u.filename,e.url)){const d=new Error(`ScriptExecutionError: Script "${e.url}" loaded but threw a runtime error during execution: ${u.message} (${u.filename}:${u.lineno}:${u.colno})`);d.name="ScriptExecutionError",i=d}}:null;c&&window.addEventListener("error",c);const l=async(u,d)=>{clearTimeout(s),c&&window.removeEventListener("error",c);const p=()=>{if(d?.type==="error"){const h=new Error(d?.isTimeout?`ScriptNetworkError: Script "${e.url}" timed out.`:`ScriptNetworkError: Failed to load script "${e.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);h.name="ScriptNetworkError",e?.onErrorCallback&&e?.onErrorCallback(h)}else i?e?.onErrorCallback&&e?.onErrorCallback(i):e?.cb&&e?.cb()};if(t&&(t.onerror=null,t.onload=null,ba(()=>{const{needDeleteScript:h=!0}=e;h&&t?.parentNode&&t.parentNode.removeChild(t)}),u&&typeof u=="function")){const h=u(d);if(h instanceof Promise){const g=await h;return p(),g}return p(),h}p()};return t.onerror=l.bind(null,t.onerror),t.onload=l.bind(null,t.onload),s=setTimeout(()=>{l(null,{type:"error",isTimeout:!0})},n),{script:t,needAttach:r}}function Kr(e){let t=null,r=!0;const n=document.getElementsByTagName("link");for(let a=0;a<n.length;a++){const i=n[a],c=i.getAttribute("href"),l=i.getAttribute("rel");if(c&&yn(c,e.url)&&l===e.attrs.rel){t=i,r=!1;break}}if(!t){t=document.createElement("link"),t.setAttribute("href",e.url);let a;const i=e.attrs;e.createLinkHook&&(a=e.createLinkHook(e.url,i),a instanceof HTMLLinkElement&&(t=a)),i&&!a&&Object.keys(i).forEach(c=>{t&&!t.getAttribute(c)&&t.setAttribute(c,i[c])})}const s=(a,i)=>{const c=()=>{i?.type==="error"?e?.onErrorCallback&&e?.onErrorCallback(i):e?.cb&&e?.cb()};if(t&&(t.onerror=null,t.onload=null,ba(()=>{const{needDeleteLink:l=!0}=e;l&&t?.parentNode&&t.parentNode.removeChild(t)}),a)){const l=a(i);return c(),l}c()};return t.onerror=s.bind(null,t.onerror),t.onload=s.bind(null,t.onload),{link:t,needAttach:r}}function du(e,t){const{attrs:r={},createScriptHook:n}=t;return new Promise((s,a)=>{const{script:i,needAttach:c}=va({url:e,cb:s,onErrorCallback:a,attrs:{fetchpriority:"high",...r},createScriptHook:n,needDeleteScript:!0});c&&document.head.appendChild(i)})}var pu=e=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}#${e.toLowerCase()}`,ya=(e,t,r,n)=>{const s=[`${[t[e]]} #${e}`];return r&&s.push(`args: ${JSON.stringify(r)}`),s.push(pu(e)),n&&s.push(`Original Error Message:
|
|
34
|
+
${n}`),s.join(`
|
|
35
|
+
`)};function fu(e,t,r,n,s,a){return n(ya(e,t,r,s))}var mt="[ Federation Runtime ]",xn=cu(mt);function Be(e,t,r,n,s){e||(r!==void 0?Ce(t,r,n,void 0):Ce(t))}function Ce(e,t,r,n,s){if(t!==void 0)return fu(e,t,r??{},i=>{throw new Error(`${mt}: ${i}`)},n);const a=e;throw a instanceof Error?(a.message.startsWith(mt)||(a.message=`${mt}: ${a.message}`),a):new Error(`${mt}: ${a}`)}function Vn(e){e instanceof Error&&(e.message.startsWith(mt)||(e.message=`${mt}: ${e.message}`)),xn.warn(e)}function mu(e,t){return e.findIndex(r=>r===t)===-1&&e.push(t),e}function Zt(e){return"version"in e&&e.version?`${e.name}:${e.version}`:"entry"in e&&e.entry?`${e.name}:${e.entry}`:`${e.name}`}function qn(e){return typeof e.entry<"u"}function xa(e){return!e.entry.includes(".json")}function Wn(e){return e&&typeof e=="object"}var hu=Object.prototype.toString;function gu(e){return hu.call(e)==="[object Object]"}function wa(e){return Array.isArray(e)?e:[e]}function ka(e){const t={url:"",type:"global",globalName:""};return"remoteEntry"in e?{url:e.remoteEntry,type:e.remoteEntryType,globalName:e.globalName}:t}var bu=(e,t)=>{let r;return e.endsWith("/")?r=e.slice(0,-1):r=e,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},Ee=typeof globalThis=="object"?globalThis:window,Ve=(()=>{try{return document.defaultView}catch{return Ee}})(),Yt=Ve;function xr(e,t,r){Object.defineProperty(e,t,{value:r,configurable:!1,writable:!0})}function wr(e,t){return Object.hasOwnProperty.call(e,t)}wr(Ee,"__GLOBAL_LOADING_REMOTE_ENTRY__")||xr(Ee,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});var Et=Ee.__GLOBAL_LOADING_REMOTE_ENTRY__;function Na(e){wr(e,"__VMOK__")&&!wr(e,"__FEDERATION__")&&xr(e,"__FEDERATION__",e.__VMOK__),wr(e,"__FEDERATION__")||(xr(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),xr(e,"__VMOK__",e.__FEDERATION__)),e.__FEDERATION__.__GLOBAL_PLUGIN__??=[],e.__FEDERATION__.__INSTANCES__??=[],e.__FEDERATION__.moduleInfo??={},e.__FEDERATION__.__SHARE__??={},e.__FEDERATION__.__MANIFEST_LOADING__??={},e.__FEDERATION__.__PRELOADED_MAP__??=new Map}Na(Ee);Na(Ve);function vu(e){Ee.__FEDERATION__.__INSTANCES__.push(e)}function yu(){return Ee.__FEDERATION__.__DEBUG_CONSTRUCTOR__}function xu(e,t=bn()){t&&(Ee.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,Ee.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="2.4.0")}function Tt(e,t){if(typeof t=="string"){if(e[t])return{value:e[t],key:t};{const r=Object.keys(e);for(const n of r){const[s,a]=n.split(":"),i=`${s}:${t}`,c=e[i];if(c)return{value:c,key:i}}return{value:void 0,key:t}}}else Ce(`getInfoWithoutType: "key" must be a string, got ${typeof t} (${JSON.stringify(t)}).`)}var Mo=()=>Ve.__FEDERATION__.moduleInfo,wu=(e,t)=>{const r=Tt(t,Zt(e)).value;if(r&&!r.version&&"version"in e&&e.version&&(r.version=e.version),r)return r;if("version"in e&&e.version){const{version:n,...s}=e,a=Zt(s),i=Tt(Ve.__FEDERATION__.moduleInfo,a).value;if(i?.version===n)return i}},kr=e=>wu(e,Ve.__FEDERATION__.moduleInfo),Eo=(e,t)=>{const r=Zt(e);return Ve.__FEDERATION__.moduleInfo[r]=t,Ve.__FEDERATION__.moduleInfo},ku=e=>(Ve.__FEDERATION__.moduleInfo={...Ve.__FEDERATION__.moduleInfo,...e},()=>{const t=Object.keys(e);for(const r of t)delete Ve.__FEDERATION__.moduleInfo[r]}),Sa=(e,t)=>{const r=t||`__FEDERATION_${e}:custom__`;return{remoteEntryKey:r,entryExports:Ee[r]}},Nu=()=>Ve.__FEDERATION__.__GLOBAL_PLUGIN__,Su=e=>Ee.__FEDERATION__.__PRELOADED_MAP__.get(e),Cu=e=>Ee.__FEDERATION__.__PRELOADED_MAP__.set(e,!0),Ao="[0-9A-Za-z-]+",Kn=`(?:\\+(${Ao}(?:\\.${Ao})*))`,Ht="0|[1-9]\\d*",Nr="[0-9]+",Ca="\\d*[a-zA-Z-][a-zA-Z0-9-]*",Po=`(?:${Nr}|${Ca})`,Mu=`(?:-?(${Po}(?:\\.${Po})*))`,Ro=`(?:${Ht}|${Ca})`,Ma=`(?:-(${Ro}(?:\\.${Ro})*))`,Zr=`${Ht}|x|X|\\*`,Dt=`[v=\\s]*(${Zr})(?:\\.(${Zr})(?:\\.(${Zr})(?:${Ma})?${Kn}?)?)?`,Eu=`^\\s*(${Dt})\\s+-\\s+(${Dt})\\s*$`,Au=`[v=\\s]*${`(${Nr})\\.(${Nr})\\.(${Nr})`}${Mu}?${Kn}?`,Zn="((?:<|>)?=?)",Pu=`(\\s*)${Zn}\\s*(${Au}|${Dt})`,Ea="(?:~>?)",Ru=`(\\s*)${Ea}\\s+`,Aa="(?:\\^)",_u=`(\\s*)${Aa}\\s+`,Iu="(<|>)?=?\\s*\\*",Tu=`^${Aa}${Dt}$`,Du=`v?${`(${Ht})\\.(${Ht})\\.(${Ht})`}${Ma}?${Kn}?`,Lu=`^${Ea}${Dt}$`,Ou=`^${Zn}\\s*${Dt}$`,$u=`^${Zn}\\s*(${Du})$|^$`,Bu="^\\s*>=\\s*0.0.0\\s*$";function Ze(e){return new RegExp(e)}function Te(e){return!e||e.toLowerCase()==="x"||e==="*"}function Pa(...e){return t=>e.reduce((r,n)=>n(r),t)}function _o(e){return e.match(Ze($u))}function Io(e,t,r,n){const s=`${e}.${t}.${r}`;return n?`${s}-${n}`:s}function zu(e){return e.replace(Ze(Eu),(t,r,n,s,a,i,c,l,u,d,p,h)=>(Te(n)?r="":Te(s)?r=`>=${n}.0.0`:Te(a)?r=`>=${n}.${s}.0`:r=`>=${r}`,Te(u)?l="":Te(d)?l=`<${Number(u)+1}.0.0-0`:Te(p)?l=`<${u}.${Number(d)+1}.0-0`:h?l=`<=${u}.${d}.${p}-${h}`:l=`<=${l}`,`${r} ${l}`.trim()))}function Fu(e){return e.replace(Ze(Pu),"$1$2$3")}function Gu(e){return e.replace(Ze(Ru),"$1~")}function Qu(e){return e.replace(Ze(_u),"$1^")}function ju(e){return e.trim().split(/\s+/).map(t=>t.replace(Ze(Tu),(r,n,s,a,i)=>Te(n)?"":Te(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:Te(a)?n==="0"?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.0 <${Number(n)+1}.0.0-0`:i?n==="0"?s==="0"?`>=${n}.${s}.${a}-${i} <${n}.${s}.${Number(a)+1}-0`:`>=${n}.${s}.${a}-${i} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a}-${i} <${Number(n)+1}.0.0-0`:n==="0"?s==="0"?`>=${n}.${s}.${a} <${n}.${s}.${Number(a)+1}-0`:`>=${n}.${s}.${a} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a} <${Number(n)+1}.0.0-0`)).join(" ")}function Uu(e){return e.trim().split(/\s+/).map(t=>t.replace(Ze(Lu),(r,n,s,a,i)=>Te(n)?"":Te(s)?`>=${n}.0.0 <${Number(n)+1}.0.0-0`:Te(a)?`>=${n}.${s}.0 <${n}.${Number(s)+1}.0-0`:i?`>=${n}.${s}.${a}-${i} <${n}.${Number(s)+1}.0-0`:`>=${n}.${s}.${a} <${n}.${Number(s)+1}.0-0`)).join(" ")}function Hu(e){return e.split(/\s+/).map(t=>t.trim().replace(Ze(Ou),(r,n,s,a,i,c)=>{const l=Te(s),u=l||Te(a),d=u||Te(i);return n==="="&&d&&(n=""),c="",l?n===">"||n==="<"?"<0.0.0-0":"*":n&&d?(u&&(a=0),i=0,n===">"?(n=">=",u?(s=Number(s)+1,a=0,i=0):(a=Number(a)+1,i=0)):n==="<="&&(n="<",u?s=Number(s)+1:a=Number(a)+1),n==="<"&&(c="-0"),`${n+s}.${a}.${i}${c}`):u?`>=${s}.0.0${c} <${Number(s)+1}.0.0-0`:d?`>=${s}.${a}.0${c} <${s}.${Number(a)+1}.0-0`:r})).join(" ")}function Vu(e){return e.trim().replace(Ze(Iu),"")}function qu(e){return e.trim().replace(Ze(Bu),"")}function Sr(e,t){return e=Number(e)||e,t=Number(t)||t,e>t?1:e===t?0:-1}function Wu(e,t){const{preRelease:r}=e,{preRelease:n}=t;if(r===void 0&&n)return 1;if(r&&n===void 0)return-1;if(r===void 0&&n===void 0)return 0;for(let s=0,a=r.length;s<=a;s++){const i=r[s],c=n[s];if(i!==c)return i===void 0&&c===void 0?0:i?c?Sr(i,c):-1:1}return 0}function dr(e,t){return Sr(e.major,t.major)||Sr(e.minor,t.minor)||Sr(e.patch,t.patch)||Wu(e,t)}function Yr(e,t){return e.version===t.version}function Ku(e,t){switch(e.operator){case"":case"=":return Yr(e,t);case">":return dr(e,t)<0;case">=":return Yr(e,t)||dr(e,t)<0;case"<":return dr(e,t)>0;case"<=":return Yr(e,t)||dr(e,t)>0;case void 0:return!0;default:return!1}}function Zu(e){return Pa(ju,Uu,Hu,Vu)(e)}function Yu(e){return Pa(zu,Fu,Gu,Qu)(e.trim()).split(/\s+/).join(" ")}function Ut(e,t){if(!e)return!1;const r=_o(e);if(!r)return!1;const[,n,,s,a,i,c]=r,l={operator:n,version:Io(s,a,i,c),major:s,minor:a,patch:i,preRelease:c?.split(".")},u=t.split("||");for(const d of u){const p=d.trim();if(!p||p==="*"||p==="x")return!0;try{const h=Yu(p);if(!h.trim())return!0;const g=h.split(" ").map(y=>Zu(y)).join(" ");if(!g.trim())return!0;const b=g.split(/\s+/).map(y=>qu(y)).filter(Boolean);if(b.length===0)continue;let v=!0;for(const y of b){const x=_o(y);if(!x){v=!1;break}const[,k,,w,N,S,M]=x;if(!Ku({operator:k,version:Io(w,N,S,M),major:w,minor:N,patch:S,preRelease:M?.split(".")},l)){v=!1;break}}if(v)return!0}catch(h){console.error(`[semver] Error processing range part "${p}":`,h);continue}}return!1}var Or="default",Xu="global";function Ju(e,t,r,n){let s;return"get"in e?s=e.get:"lib"in e?s=()=>Promise.resolve(e.lib):s=()=>Promise.resolve(()=>{Ce(`Cannot get shared "${r}" from "${t}": neither "get" nor "lib" is provided in the share config.`)}),e.shareConfig?.eager&&e.treeShaking?.mode&&Ce(`Invalid shared config for "${r}" from "${t}": cannot use both "eager: true" and "treeShaking.mode" simultaneously. Choose one strategy.`),{deps:[],useIn:[],from:t,loading:null,...e,shareConfig:{requiredVersion:`^${e.version}`,singleton:!1,eager:!1,strictVersion:!1,...e.shareConfig},get:s,loaded:e?.loaded||"lib"in e?!0:void 0,version:e.version??"0",scope:Array.isArray(e.scope)?e.scope:[e.scope??"default"],strategy:(e.strategy??n)||"version-first",treeShaking:e.treeShaking?{...e.treeShaking,mode:e.treeShaking.mode??"server-calc",status:e.treeShaking.status??gn.UNKNOWN,useIn:[]}:void 0}}function Ra(e,t){const r=t.shared||{},n=t.name,s=Object.keys(r).reduce((i,c)=>{const l=wa(r[c]);return i[c]=i[c]||[],l.forEach(u=>{i[c].push(Ju(u,n,c,t.shareStrategy))}),i},{}),a={...e.shared};return Object.keys(s).forEach(i=>{a[i]?s[i].forEach(c=>{a[i].find(l=>l.version===c.version)||a[i].push(c)}):a[i]=s[i]}),{allShareInfos:a,newShareInfos:s}}function Xt(e,t){if(!e)return!1;const{status:r,mode:n}=e;return r===gn.NO_USE?!1:r===gn.CALCULATED?!0:n==="runtime-infer"?t?td(e,t):!0:!1}function ht(e,t){const r=n=>{if(!Number.isNaN(Number(n))){const s=n.split(".");let a=n;for(let i=0;i<3-s.length;i++)a+=".0";return a}return n};return!!Ut(r(e),`<=${r(t)}`)}var Jt=(e,t)=>{const r=t||function(n,s){return ht(n,s)};return Object.keys(e).reduce((n,s)=>!n||r(n,s)||n==="0"?s:n,0)},Pr=e=>!!e.loaded||typeof e.lib=="function",ed=e=>!!e.loading,td=(e,t)=>{if(!e||!t)return!1;const{usedExports:r}=e;return r?!!t.every(n=>r.includes(n)):!1};function rd(e,t,r,n){const s=e[t][r];let a="",i=Xt(n);const c=function(l,u){return i?s[l].treeShaking?s[u].treeShaking?!Pr(s[l].treeShaking)&&ht(l,u):!1:!0:!Pr(s[l])&&ht(l,u)};if(i){if(a=Jt(e[t][r],c),a)return{version:a,useTreesShaking:i};i=!1}return{version:Jt(e[t][r],c),useTreesShaking:i}}var St=e=>Pr(e)||ed(e);function nd(e,t,r,n){const s=e[t][r];let a="",i=Xt(n);const c=function(l,u){if(i){if(!s[l].treeShaking)return!0;if(!s[u].treeShaking)return!1;if(St(s[u].treeShaking))return St(s[l].treeShaking)?!!ht(l,u):!0;if(St(s[l].treeShaking))return!1}return St(s[u])?St(s[l])?!!ht(l,u):!0:St(s[l])?!1:ht(l,u)};if(i){if(a=Jt(e[t][r],c),a)return{version:a,useTreesShaking:i};i=!1}return{version:Jt(e[t][r],c),useTreesShaking:i}}function od(e){return e==="loaded-first"?nd:rd}function Cr(e,t,r,n){if(!e)return;const{shareConfig:s,scope:a=Or,strategy:i,treeShaking:c}=r,l=Array.isArray(a)?a:[a];for(const u of l)if(s&&e[u]&&e[u][t]){const{requiredVersion:d}=s,{version:p,useTreesShaking:h}=od(i)(e,u,t,c),g=()=>{const v=e[u][t][p];if(s.singleton){if(typeof d=="string"&&!Ut(p,d)){const y=`Version ${p} from ${p&&v.from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${d})`;s.strictVersion?Ce(y):Vn(y)}return{shared:v,useTreesShaking:h}}else{if(d===!1||d==="*")return{shared:v,useTreesShaking:h};if(Ut(p,d))return{shared:v,useTreesShaking:h};const y=Xt(c);if(y){for(const[x,k]of Object.entries(e[u][t]))if(Xt(k.treeShaking,c?.usedExports)&&Ut(x,d))return{shared:k,useTreesShaking:y}}for(const[x,k]of Object.entries(e[u][t]))if(Ut(x,d))return{shared:k,useTreesShaking:!1}}},b={shareScopeMap:e,scope:u,pkgName:t,version:p,GlobalFederation:Yt.__FEDERATION__,shareInfo:r,resolver:g};return(n.emit(b)||b).resolver()}}function _a(){return Yt.__FEDERATION__.__SHARE__}function To(e){const{pkgName:t,extraOptions:r,shareInfos:n}=e,s=l=>{if(!l)return;const u={};return l.forEach(p=>{u[p.version]=p}),u[Jt(u,function(p,h){return!Pr(u[p])&&ht(p,h)})]},a=r?.resolver??s,i=l=>l!==null&&typeof l=="object"&&!Array.isArray(l),c=(...l)=>{const u={};for(const d of l)if(d)for(const[p,h]of Object.entries(d)){const g=u[p];i(g)&&i(h)?u[p]=c(g,h):h!==void 0&&(u[p]=h)}return u};return c(a(n[t]),r?.customShareInfo)}var Ct=(e,t)=>{e.useIn||(e.useIn=[]),mu(e.useIn,t)};function pr(e,t){return t&&e.treeShaking?e.treeShaking:e}function sd(e,t){for(const r of e){const n=t.startsWith(r.name);let s=t.replace(r.name,"");if(n){if(s.startsWith("/")){const c=r.name;return s=`.${s}`,{pkgNameOrAlias:c,expose:s,remote:r}}else if(s==="")return{pkgNameOrAlias:r.name,expose:".",remote:r}}const a=r.alias&&t.startsWith(r.alias);let i=r.alias&&t.replace(r.alias,"");if(r.alias&&a){if(i&&i.startsWith("/")){const c=r.alias;return i=`.${i}`,{pkgNameOrAlias:c,expose:i,remote:r}}else if(i==="")return{pkgNameOrAlias:r.alias,expose:".",remote:r}}}}function ad(e,t){for(const r of e)if(t===r.name||r.alias&&t===r.alias)return r}var Ia="RUNTIME-001",Ta="RUNTIME-002",Da="RUNTIME-003",La="RUNTIME-004",Oa="RUNTIME-005",wn="RUNTIME-006",$a="RUNTIME-007",Ba="RUNTIME-008",Yn="RUNTIME-009",za="RUNTIME-010",Fa="RUNTIME-011",id="RUNTIME-012",ze={[Ia]:"Failed to get remoteEntry exports.",[Ta]:'The remote entry interface does not contain "init"',[Da]:"Failed to get manifest.",[La]:"Failed to locate remote.",[Oa]:"Invalid loadShareSync function call from bundler runtime",[wn]:"Invalid loadShareSync function call from runtime",[$a]:"Failed to get remote snapshot.",[Ba]:"Failed to load script resources.",[Yn]:"Please call createInstance first.",[za]:'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',[Fa]:"The remoteEntry URL is missing from the remote snapshot.",[id]:'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.'};({...ze});var Ga=".then(callbacks[0]).catch(callbacks[1])";async function ld({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${e}")${Ga}`)([r,n]):import(e).then(r).catch(n)}catch(s){Ce(`Failed to load ESM entry from "${e}". ${s instanceof Error?s.message:String(s)}`)}})}async function cd({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof __system_context__>"u"?System.import(e).then(r).catch(n):new Function("callbacks",`System.import("${e}")${Ga}`)([r,n])}catch(s){Ce(`Failed to load SystemJS entry from "${e}". ${s instanceof Error?s.message:String(s)}`)}})}function ud(e,t,r){const{remoteEntryKey:n,entryExports:s}=Sa(e,t);return s||Ce(Ia,ze,{remoteName:e,remoteEntryUrl:r,remoteEntryKey:n}),s}async function dd({name:e,globalName:t,entry:r,remoteInfo:n,loaderHook:s,getEntryUrl:a}){const{entryExports:i}=Sa(e,t);if(i)return i;const c=a?a(r):r;return du(c,{attrs:{},createScriptHook:(l,u)=>{const d=s.lifecycle.createScript.emit({url:l,attrs:u,remoteInfo:n});if(d&&(d instanceof HTMLScriptElement||"script"in d||"timeout"in d))return d}}).then(()=>ud(e,t,r),l=>{const u=l instanceof Error?l.message:String(l);Ce(Ba,ze,{remoteName:e,resourceUrl:c},u)})}async function pd({remoteInfo:e,remoteEntryExports:t,loaderHook:r,getEntryUrl:n}){const{entry:s,entryGlobalName:a,name:i,type:c}=e;switch(c){case"esm":case"module":return ld({entry:s,remoteEntryExports:t});case"system":return cd({entry:s,remoteEntryExports:t});default:return dd({entry:s,globalName:a,name:i,remoteInfo:e,loaderHook:r,getEntryUrl:n})}}function kn(e){const{entry:t,name:r}=e;return pa(r,t)}async function Rr(e){const{origin:t,remoteEntryExports:r,remoteInfo:n,getEntryUrl:s,_inErrorHandling:a=!1}=e,i=kn(n);if(r)return r;if(!Et[i]){const c=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;Et[i]=c.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:r}).then(u=>u||pd({remoteInfo:n,remoteEntryExports:r,loaderHook:l,getEntryUrl:s})).catch(async u=>{const d=kn(n),p=u instanceof Error&&u.message.includes("ScriptExecutionError");if(u instanceof Error&&u.message.includes("RUNTIME-008")&&!p&&!a){const h=b=>Rr({...b,_inErrorHandling:!0}),g=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:h,origin:t,remoteInfo:n,remoteEntryExports:r,globalLoading:Et,uniqueKey:d});if(g)return g}throw u})}return Et[i]}function _r(e){return{...e,entry:"entry"in e?e.entry:"",type:e.type||"global",entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||"default"}}function fd(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function md(e,t){const r=Nu(),n=[t.hooks,t.remoteHandler.hooks,t.sharedHandler.hooks,t.snapshotHandler.hooks,t.loaderHook,t.bridgeHook];return r.length>0&&r.forEach(s=>{e?.find(a=>a.name!==s.name)&&e.push(s)}),e&&e.length>0&&e.forEach(s=>{n.forEach(a=>{a.applyPlugin(s,t)})}),e}function hd(e){return{name:e.name,alias:e.alias,entry:"entry"in e?e.entry:void 0,version:"version"in e?e.version:void 0,type:e.type,entryGlobalName:e.entryGlobalName,shareScope:e.shareScope}}function Lt(e){const t={};for(const[r,n]of Object.entries(e.shared)){const s=n[0];s&&(t[r]={version:s.version,singleton:s.shareConfig?.singleton,requiredVersion:s.shareConfig?.requiredVersion===!1?!1:s.shareConfig?.requiredVersion,eager:s.eager,strictVersion:s.shareConfig?.strictVersion})}return{project:{name:e.name,mfRole:e.remotes?.length>0?"host":"unknown"},mfConfig:{name:e.name,remotes:e.remotes?.map(hd)??[],shared:t}}}function Qa(e){return{resourceCategory:"sync",share:!0,depsRemote:!0,...e}}function gd(e,t){return t.map(r=>{const n=ad(e,r.nameOrAlias);return Be(n,`Unable to preload ${r.nameOrAlias} as it is not included in ${!n&&ma({remoteInfo:n,remotes:e})}`),{remote:n,preloadConfig:Qa(r)}})}function bd(e){return e?e.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function ja(e,t,r,n=!0){const{cssAssets:s,jsAssetsWithoutEntry:a,entryAssets:i}=r;if(t.options.inBrowser){if(i.forEach(c=>{const{moduleInfo:l}=c,u=t.moduleCache.get(e.name);Rr(u?{origin:t,remoteInfo:l,remoteEntryExports:u.remoteEntryExports}:{origin:t,remoteInfo:l,remoteEntryExports:void 0})}),n){const c={rel:"preload",as:"style"};s.forEach(l=>{const{link:u,needAttach:d}=Kr({url:l,cb:()=>{},attrs:c,createLinkHook:(p,h)=>{const g=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:h,remoteInfo:e});if(g instanceof HTMLLinkElement)return g}});d&&document.head.appendChild(u)})}else{const c={rel:"stylesheet",type:"text/css"};s.forEach(l=>{const{link:u,needAttach:d}=Kr({url:l,cb:()=>{},attrs:c,createLinkHook:(p,h)=>{const g=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:h,remoteInfo:e});if(g instanceof HTMLLinkElement)return g},needDeleteLink:!1});d&&document.head.appendChild(u)})}if(n){const c={rel:"preload",as:"script"};a.forEach(l=>{const{link:u,needAttach:d}=Kr({url:l,cb:()=>{},attrs:c,createLinkHook:(p,h)=>{const g=t.loaderHook.lifecycle.createLink.emit({url:p,attrs:h,remoteInfo:e});if(g instanceof HTMLLinkElement)return g}});d&&document.head.appendChild(u)})}else{const c={fetchpriority:"high",type:e?.type==="module"?"module":"text/javascript"};a.forEach(l=>{const{script:u,needAttach:d}=va({url:l,cb:()=>{},attrs:c,createScriptHook:(p,h)=>{const g=t.loaderHook.lifecycle.createScript.emit({url:p,attrs:h,remoteInfo:e});if(g instanceof HTMLScriptElement)return g},needDeleteScript:!0});d&&document.head.appendChild(u)})}}}function vd(e,t,r){const n=t,s=Array.isArray(e.shareScope)?e.shareScope:[e.shareScope];s.length||s.push("default"),s.forEach(i=>{n[i]||(n[i]={})});const a={version:e.version||"",shareScopeKeys:Array.isArray(e.shareScope)?s:e.shareScope||"default"};return Object.defineProperty(a,"shareScopeMap",{value:n,enumerable:!1}),{remoteEntryInitOptions:a,shareScope:n[s[0]],initScope:r??[]}}var Ua=class{constructor({remoteInfo:e,host:t}){this.inited=!1,this.initing=!1,this.lib=void 0,this.remoteInfo=e,this.host=t}async getEntry(){if(this.remoteEntryExports)return this.remoteEntryExports;const e=await Rr({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return Be(e,`remoteEntryExports is undefined
|
|
36
|
+
${ma(this.remoteInfo)}`),this.remoteEntryExports=e,this.remoteEntryExports}async init(e,t,r){const n=await this.getEntry();if(this.inited)return n;if(this.initPromise)return await this.initPromise,n;this.initing=!0,this.initPromise=(async()=>{const{remoteEntryInitOptions:s,shareScope:a,initScope:i}=vd(this.remoteInfo,this.host.shareScopeMap,r),c=await this.host.hooks.lifecycle.beforeInitContainer.emit({shareScope:a,remoteEntryInitOptions:s,initScope:i,remoteInfo:this.remoteInfo,origin:this.host});typeof n?.init>"u"&&Ce(Ta,ze,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName},void 0,Lt(this.host.options)),await n.init(c.shareScope,c.initScope,c.remoteEntryInitOptions),await this.host.hooks.lifecycle.initContainer.emit({...c,id:e,remoteSnapshot:t,remoteEntryExports:n}),this.inited=!0})();try{await this.initPromise}finally{this.initing=!1,this.initPromise=void 0}return n}async get(e,t,r,n){const{loadFactory:s=!0}=r||{loadFactory:!0},a=await this.init(e,n);this.lib=a;let i;i=await this.host.loaderHook.lifecycle.getModuleFactory.emit({remoteEntryExports:a,expose:t,moduleInfo:this.remoteInfo}),i||(i=await a.get(t)),Be(i,`${Zt(this.remoteInfo)} remote don't export ${t}.`);const c=bu(this.remoteInfo.name,t),l=this.wraperFactory(i,c);return s?await l():l}wraperFactory(e,t){function r(n,s){n&&typeof n=="object"&&Object.isExtensible(n)&&!Object.getOwnPropertyDescriptor(n,Symbol.for("mf_module_id"))&&Object.defineProperty(n,Symbol.for("mf_module_id"),{value:s,enumerable:!1})}return e instanceof Promise?async()=>{const n=await e();return r(n,t),n}:()=>{const n=e();return r(n,t),n}}},Qe=class{constructor(e){this.type="",this.listeners=new Set,e&&(this.type=e)}on(e){typeof e=="function"&&this.listeners.add(e)}once(e){const t=this;this.on(function r(...n){return t.remove(r),e.apply(null,n)})}emit(...e){let t;return this.listeners.size>0&&this.listeners.forEach(r=>{t=r(...e)}),t}remove(e){this.listeners.delete(e)}removeAll(){this.listeners.clear()}},Ue=class extends Qe{emit(...e){let t;const r=Array.from(this.listeners);if(r.length>0){let n=0;const s=a=>a===!1?!1:n<r.length?Promise.resolve(r[n++].apply(null,e)).then(s):a;t=s()}return Promise.resolve(t)}};function Ha(e,t){if(!Wn(t))return!1;if(e!==t){for(const r in e)if(!(r in t))return!1}return!0}var Rt=class extends Qe{constructor(e){super(),this.onerror=Ce,this.type=e}emit(e){Wn(e)||Ce(`The data for the "${this.type}" hook should be an object.`);for(const t of this.listeners)try{const r=t(e);if(Ha(e,r))e=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){Vn(r),this.onerror(r)}return e}},st=class extends Qe{constructor(e){super(),this.onerror=Ce,this.type=e}emit(e){Wn(e)||Ce(`The response data for the "${this.type}" hook must be an object.`);const t=Array.from(this.listeners);if(t.length>0){let r=0;const n=a=>(Vn(a),this.onerror(a),e),s=a=>{if(Ha(e,a)){if(e=a,r<t.length)try{return Promise.resolve(t[r++](e)).then(s,n)}catch(i){return n(i)}}else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);return e};return Promise.resolve(s(e))}return Promise.resolve(e)}},_t=class{constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}applyPlugin(e,t){Be(gu(e),"Plugin configuration is invalid.");const r=e.name;Be(r,"A name must be provided by the plugin."),this.registerPlugins[r]||(this.registerPlugins[r]=e,e.apply?.(t),Object.keys(this.lifecycle).forEach(n=>{const s=e[n];s&&this.lifecycle[n].on(s)}))}removePlugin(e){Be(e,"A name is required.");const t=this.registerPlugins[e];Be(t,`The plugin "${e}" is not registered.`),Object.keys(t).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(t[r])})}};function Va(e,t){const r=ka(t);r.url||Ce(Fa,ze,{remoteName:e.name});let n=vn(t,r.url);e.type=r.type,e.entryGlobalName=r.globalName,e.entry=n,e.version=t.version,e.buildVersion=t.buildVersion}function yd(){return{name:"snapshot-plugin",async afterResolve(e){const{remote:t,pkgNameOrAlias:r,expose:n,origin:s,remoteInfo:a,id:i}=e;if(!qn(t)||!xa(t)){const{remoteSnapshot:c,globalSnapshot:l}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:i});Va(a,c);const u={remote:t,preloadConfig:{nameOrAlias:r,exposes:[n],resourceCategory:"sync",share:!1,depsRemote:!1}},d=await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({origin:s,preloadOptions:u,remoteInfo:a,remote:t,remoteSnapshot:c,globalSnapshot:l});return d&&ja(a,s,d,!1),{...e,remoteSnapshot:c}}return e}}}function xd(e){const t=e.split(":");return t.length===1?{name:t[0],version:void 0}:t.length===2?{name:t[0],version:t[1]}:{name:t[1],version:t[2]}}function qa(e,t,r,n,s={},a){const{value:i}=Tt(e,Zt(t)),c=a||i;if(c&&!ha(c)&&(r(c,t,n),c.remotesInfo)){const l=Object.keys(c.remotesInfo);for(const u of l){if(s[u])continue;s[u]=!0;const d=xd(u),p=c.remotesInfo[u];qa(e,{name:d.name,version:p.matchedVersion},r,!1,s,void 0)}}}var Xr=(e,t)=>document.querySelector(`${e}[${e==="link"?"href":"src"}="${t}"]`);function wd(e,t,r,n,s){const a=[],i=[],c=[],l=new Set,u=new Set,{options:d}=e,{preloadConfig:p}=t,{depsRemote:h}=p;if(qa(n,r,(b,v,y)=>{let x;if(y)x=p;else if(Array.isArray(h)){const M=h.find(P=>P.nameOrAlias===v.name||P.nameOrAlias===v.alias);if(!M)return;x=Qa(M)}else if(h===!0)x=p;else return;const k=vn(b,ka(b).url);k&&c.push({name:v.name,moduleInfo:{name:v.name,entry:k,type:"remoteEntryType"in b?b.remoteEntryType:"global",entryGlobalName:"globalName"in b?b.globalName:v.name,shareScope:"",version:"version"in b?b.version:void 0},url:k});let w="modules"in b?b.modules:[];const N=bd(x.exposes);N.length&&"modules"in b&&(w=b?.modules?.reduce((M,P)=>(N?.indexOf(P.moduleName)!==-1&&M.push(P),M),[]));function S(M){const P=M.map(A=>vn(b,A));return x.filter?P.filter(x.filter):P}if(w){const M=w.length;for(let P=0;P<M;P++){const A=w[P],V=`${v.name}/${A.moduleName}`;e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:A.moduleName==="."?v.name:V,name:v.name,remoteSnapshot:b,preloadConfig:x,remote:v,origin:e}),!Su(V)&&(x.resourceCategory==="all"?(a.push(...S(A.assets.css.async)),a.push(...S(A.assets.css.sync)),i.push(...S(A.assets.js.async)),i.push(...S(A.assets.js.sync))):x.resourceCategory==="sync"&&(a.push(...S(A.assets.css.sync)),i.push(...S(A.assets.js.sync))),Cu(V))}}},!0,{},s),s.shared&&s.shared.length>0){const b=(v,y)=>{const{shared:x}=Cr(e.shareScopeMap,y.sharedName,v,e.sharedHandler.hooks.lifecycle.resolveShare)||{};x&&typeof x.lib=="function"&&(y.assets.js.sync.forEach(k=>{l.add(k)}),y.assets.css.sync.forEach(k=>{u.add(k)}))};s.shared.forEach(v=>{const y=d.shared?.[v.sharedName];if(!y)return;const x=v.version?y.find(k=>k.version===v.version):y;x&&wa(x).forEach(k=>{b(k,v)})})}const g=i.filter(b=>!l.has(b)&&!Xr("script",b));return{cssAssets:a.filter(b=>!u.has(b)&&!Xr("link",b)),jsAssetsWithoutEntry:g,entryAssets:c.filter(b=>!Xr("script",b.url))}}var kd=function(){return{name:"generate-preload-assets-plugin",async generatePreloadAssets(e){const{origin:t,preloadOptions:r,remoteInfo:n,remote:s,globalSnapshot:a,remoteSnapshot:i}=e;return qn(s)&&xa(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:n.name,entry:s.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(Va(n,i),wd(t,r,n,a,i))}}};function Wa(e,t){const r=kr({name:t.name,version:t.options.version}),n=r&&"remotesInfo"in r&&r.remotesInfo&&Tt(r.remotesInfo,e.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:Mo(),remoteSnapshot:kr({name:e.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:Mo(),remoteSnapshot:kr({name:e.name,version:"version"in e?e.version:void 0})}}var Nd=class{constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new _t({beforeLoadRemoteSnapshot:new Ue("beforeLoadRemoteSnapshot"),loadSnapshot:new st("loadGlobalSnapshot"),loadRemoteSnapshot:new st("loadRemoteSnapshot"),afterLoadSnapshot:new st("afterLoadSnapshot")}),this.manifestLoading=Yt.__FEDERATION__.__MANIFEST_LOADING__,this.HostInstance=e,this.loaderHook=e.loaderHook}async loadRemoteSnapshotInfo({moduleInfo:e,id:t,expose:r}){const{options:n}=this.HostInstance;await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({options:n,moduleInfo:e});let s=kr({name:this.HostInstance.options.name,version:this.HostInstance.options.version});s||(s={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},ku({[this.HostInstance.options.name]:s})),s&&"remotesInfo"in s&&!Tt(s.remotesInfo,e.name).value&&("version"in e||"entry"in e)&&(s.remotesInfo={...s?.remotesInfo,[e.name]:{matchedVersion:"version"in e?e.version:e.entry}});const{hostGlobalSnapshot:a,remoteSnapshot:i,globalSnapshot:c}=this.getGlobalRemoteInfo(e),{remoteSnapshot:l,globalSnapshot:u}=await this.hooks.lifecycle.loadSnapshot.emit({options:n,moduleInfo:e,hostGlobalSnapshot:a,remoteSnapshot:i,globalSnapshot:c});let d,p;if(l)if(ha(l)){const h=l.remoteEntry,g=await this.getManifestJson(h,e,{}),b=Eo({...e,entry:h},g);d=g,p=b}else{const{remoteSnapshot:h}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:l,from:"global"});d=h,p=u}else if(qn(e)){const h=await this.getManifestJson(e.entry,e,{}),g=Eo(e,h),{remoteSnapshot:b}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:e,remoteSnapshot:h,from:"global"});d=b,p=g}else Ce($a,ze,{remoteName:e.name,remoteVersion:e.version,hostName:this.HostInstance.options.name,globalSnapshot:JSON.stringify(u)},void 0,Lt(this.HostInstance.options));return await this.hooks.lifecycle.afterLoadSnapshot.emit({id:t,host:this.HostInstance,options:n,moduleInfo:e,remoteSnapshot:d}),{remoteSnapshot:d,globalSnapshot:p}}getGlobalRemoteInfo(e){return Wa(e,this.HostInstance)}async getManifestJson(e,t,r){const n=async()=>{let a=this.manifestCache.get(e);if(a)return a;try{let i=await this.loaderHook.lifecycle.fetch.emit(e,{},_r(t));(!i||!(i instanceof Response))&&(i=await fetch(e,{})),a=await i.json()}catch(i){a=await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:e,error:i,from:"runtime",lifecycle:"afterResolve",origin:this.HostInstance}),a||(delete this.manifestLoading[e],Ce(Da,ze,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},`${i}`,Lt(this.HostInstance.options)))}return Be(a.metaData&&a.exposes&&a.shared,`"${e}" is not a valid federation manifest for remote "${t.name}". Missing required fields: ${[!a.metaData&&"metaData",!a.exposes&&"exposes",!a.shared&&"shared"].filter(Boolean).join(", ")}.`),this.manifestCache.set(e,a),a},s=async()=>{const a=await n(),i=su(a,{version:e}),{remoteSnapshot:c}=await this.hooks.lifecycle.loadRemoteSnapshot.emit({options:this.HostInstance.options,moduleInfo:t,manifestJson:a,remoteSnapshot:i,manifestUrl:e,from:"manifest"});return c};return this.manifestLoading[e]||(this.manifestLoading[e]=s().then(a=>a)),this.manifestLoading[e]}},Sd=class{constructor(e){this.hooks=new _t({beforeRegisterShare:new Rt("beforeRegisterShare"),afterResolve:new st("afterResolve"),beforeLoadShare:new st("beforeLoadShare"),loadShare:new Ue,resolveShare:new Rt("resolveShare"),initContainerShareScopeMap:new Rt("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}registerShared(e,t){const{newShareInfos:r,allShareInfos:n}=Ra(e,t);return Object.keys(r).forEach(s=>{r[s].forEach(a=>{a.scope.forEach(i=>{this.hooks.lifecycle.beforeRegisterShare.emit({origin:this.host,pkgName:s,shared:a}),this.shareScopeMap[i]?.[s]||this.setShared({pkgName:s,lib:a.lib,get:a.get,loaded:a.loaded||!!a.lib,shared:a,from:t.name})})})}),{newShareInfos:r,allShareInfos:n}}async loadShare(e,t){const{host:r}=this,n=To({pkgName:e,extraOptions:t,shareInfos:r.options.shared});n?.scope&&await Promise.all(n.scope.map(async c=>{await Promise.all(this.initializeSharing(c,{strategy:n.strategy}))}));const{shareInfo:s}=await this.hooks.lifecycle.beforeLoadShare.emit({pkgName:e,shareInfo:n,shared:r.options.shared,origin:r});Be(s,`Cannot find shared "${e}" in host "${r.options.name}". Ensure the shared config for "${e}" is declared in the federation plugin options and the host has been initialized before loading shares.`);const{shared:a,useTreesShaking:i}=Cr(this.shareScopeMap,e,s,this.hooks.lifecycle.resolveShare)||{};if(a){const c=pr(a,i);if(c.lib)return Ct(c,r.options.name),c.lib;if(c.loading&&!c.loaded){const l=await c.loading;return c.loaded=!0,c.lib||(c.lib=l),Ct(c,r.options.name),l}else{const u=(async()=>{const d=await c.get();return Ct(c,r.options.name),c.loaded=!0,c.lib=d,d})();return this.setShared({pkgName:e,loaded:!1,shared:a,from:r.options.name,lib:null,loading:u,treeShaking:i?c:void 0}),u}}else{if(t?.customShareInfo)return!1;const c=Xt(s.treeShaking),l=pr(s,c),d=(async()=>{const p=await l.get();l.lib=p,l.loaded=!0,Ct(l,r.options.name);const{shared:h,useTreesShaking:g}=Cr(this.shareScopeMap,e,s,this.hooks.lifecycle.resolveShare)||{};if(h){const b=pr(h,g);b.lib=p,b.loaded=!0,h.from=s.from}return p})();return this.setShared({pkgName:e,loaded:!1,shared:s,from:r.options.name,lib:null,loading:d,treeShaking:c?l:void 0}),d}}initializeSharing(e=Or,t){const{host:r}=this,n=t?.from,s=t?.strategy;let a=t?.initScope;const i=[];if(n!=="build"){const{initTokens:h}=this;a||(a=[]);let g=h[e];if(g||(g=h[e]={from:this.host.name}),a.indexOf(g)>=0)return i;a.push(g)}const c=this.shareScopeMap,l=r.options.name;c[e]||(c[e]={});const u=c[e],d=(h,g)=>{const{version:b,eager:v}=g;u[h]=u[h]||{};const y=u[h],x=y[b]&&pr(y[b]),k=!!(x&&("eager"in x&&x.eager||"shareConfig"in x&&x.shareConfig?.eager));(!x||x.strategy!=="loaded-first"&&!x.loaded&&(!v!=!k?v:l>y[b].from))&&(y[b]=g)},p=async h=>{const{module:g}=await r.remoteHandler.getRemoteModuleAndOptions({id:h});let b;try{b=await g.getEntry()}catch(v){if(b=await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({id:h,error:v,from:"runtime",lifecycle:"beforeLoadShare",origin:r}),!b)return}finally{b?.init&&!g.initing&&(g.remoteEntryExports=b,await g.init(void 0,void 0,a))}};return Object.keys(r.options.shared).forEach(h=>{r.options.shared[h].forEach(g=>{g.scope.includes(e)&&d(h,g)})}),(r.options.shareStrategy==="version-first"||s==="version-first")&&r.options.remotes.forEach(h=>{h.shareScope===e&&i.push(p(h.name))}),i}loadShareSync(e,t){const{host:r}=this,n=To({pkgName:e,extraOptions:t,shareInfos:r.options.shared});n?.scope&&n.scope.forEach(i=>{this.initializeSharing(i,{strategy:n.strategy})});const{shared:s,useTreesShaking:a}=Cr(this.shareScopeMap,e,n,this.hooks.lifecycle.resolveShare)||{};if(s){if(typeof s.lib=="function")return Ct(s,r.options.name),s.loaded||(s.loaded=!0,s.from===r.options.name&&(n.loaded=!0)),s.lib;if(typeof s.get=="function"){const i=s.get();if(!(i instanceof Promise))return Ct(s,r.options.name),this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:i,shared:s}),i}}if(n.lib)return n.loaded||(n.loaded=!0),n.lib;if(n.get){const i=n.get();return i instanceof Promise&&Ce(t?.from==="build"?Oa:wn,ze,{hostName:r.options.name,sharedPkgName:e},void 0,Lt(r.options)),n.lib=i,this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:n.lib,shared:n}),n.lib}Ce(wn,ze,{hostName:r.options.name,sharedPkgName:e},void 0,Lt(r.options))}initShareScopeMap(e,t,r={}){const{host:n}=this;this.shareScopeMap[e]=t,this.hooks.lifecycle.initContainerShareScopeMap.emit({shareScope:t,options:n.options,origin:n,scopeName:e,hostShareScopeMap:r.hostShareScopeMap})}setShared({pkgName:e,shared:t,from:r,lib:n,loading:s,loaded:a,get:i,treeShaking:c}){const{version:l,scope:u="default",...d}=t,p=Array.isArray(u)?u:[u],h=g=>{const b=(y,x,k)=>{k&&!y[x]&&(y[x]=k)},v=c?g.treeShaking:g;b(v,"loaded",a),b(v,"loading",s),b(v,"get",i)};p.forEach(g=>{this.shareScopeMap[g]||(this.shareScopeMap[g]={}),this.shareScopeMap[g][e]||(this.shareScopeMap[g][e]={}),this.shareScopeMap[g][e][l]||(this.shareScopeMap[g][e][l]={version:l,scope:[g],...d,lib:n});const b=this.shareScopeMap[g][e][l];h(b),r&&b.from!==r&&(b.from=r)})}_setGlobalShareScopeMap(e){const t=_a(),r=e.id||e.name;r&&!t[r]&&(t[r]=this.shareScopeMap)}},Cd=class{constructor(e){this.hooks=new _t({beforeRegisterRemote:new Rt("beforeRegisterRemote"),registerRemote:new Rt("registerRemote"),beforeRequest:new st("beforeRequest"),onLoad:new Ue("onLoad"),handlePreloadModule:new Qe("handlePreloadModule"),errorLoadRemote:new Ue("errorLoadRemote"),beforePreloadRemote:new Ue("beforePreloadRemote"),generatePreloadAssets:new Ue("generatePreloadAssets"),afterPreloadRemote:new Ue,loadEntry:new Ue}),this.host=e,this.idToRemoteMap={}}formatAndRegisterRemote(e,t){return(t.remotes||[]).reduce((r,n)=>(this.registerRemote(n,r,{force:!1}),r),e.remotes)}setIdToRemoteMap(e,t){const{remote:r,expose:n}=t,{name:s,alias:a}=r;if(this.idToRemoteMap[e]={name:r.name,expose:n},a&&e.startsWith(s)){const i=e.replace(s,a);this.idToRemoteMap[i]={name:r.name,expose:n};return}if(a&&e.startsWith(a)){const i=e.replace(a,s);this.idToRemoteMap[i]={name:r.name,expose:n}}}async loadRemote(e,t){const{host:r}=this;try{const{loadFactory:n=!0}=t||{loadFactory:!0},{module:s,moduleOptions:a,remoteMatchInfo:i}=await this.getRemoteModuleAndOptions({id:e}),{pkgNameOrAlias:c,remote:l,expose:u,id:d,remoteSnapshot:p}=i,h=await s.get(d,u,t,p),g=await this.hooks.lifecycle.onLoad.emit({id:d,pkgNameOrAlias:c,expose:u,exposeModule:n?h:void 0,exposeModuleFactory:n?void 0:h,remote:l,options:a,moduleInstance:s,origin:r});return this.setIdToRemoteMap(e,i),typeof g=="function"?g:h}catch(n){const{from:s="runtime"}=t||{from:"runtime"},a=await this.hooks.lifecycle.errorLoadRemote.emit({id:e,error:n,from:s,lifecycle:"onLoad",origin:r});if(!a)throw n;return a}}async preloadRemote(e){const{host:t}=this;await this.hooks.lifecycle.beforePreloadRemote.emit({preloadOps:e,options:t.options,origin:t});const r=gd(t.options.remotes,e);await Promise.all(r.map(async n=>{const{remote:s}=n,a=_r(s),{globalSnapshot:i,remoteSnapshot:c}=await t.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:s}),l=await this.hooks.lifecycle.generatePreloadAssets.emit({origin:t,preloadOptions:n,remote:s,remoteInfo:a,globalSnapshot:i,remoteSnapshot:c});l&&ja(a,t,l)}))}registerRemotes(e,t){const{host:r}=this;e.forEach(n=>{this.registerRemote(n,r.options.remotes,{force:t?.force})})}async getRemoteModuleAndOptions(e){const{host:t}=this,{id:r}=e;let n;try{n=await this.hooks.lifecycle.beforeRequest.emit({id:r,options:t.options,origin:t})}catch(g){if(n=await this.hooks.lifecycle.errorLoadRemote.emit({id:r,options:t.options,origin:t,from:"runtime",error:g,lifecycle:"beforeRequest"}),!n)throw g}const{id:s}=n,a=sd(t.options.remotes,s);a||Ce(La,ze,{hostName:t.options.name,requestId:s},void 0,Lt(t.options));const{remote:i}=a,c=_r(i),l=await t.sharedHandler.hooks.lifecycle.afterResolve.emit({id:s,...a,options:t.options,origin:t,remoteInfo:c}),{remote:u,expose:d}=l;Be(u&&d,`The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${s}.`);let p=t.moduleCache.get(u.name);const h={host:t,remoteInfo:c};return p||(p=new Ua(h),t.moduleCache.set(u.name,p)),{module:p,moduleOptions:h,remoteMatchInfo:l}}registerRemote(e,t,r){const{host:n}=this,s=()=>{if(e.alias){const i=t.find(c=>e.alias&&(c.name.startsWith(e.alias)||c.alias?.startsWith(e.alias)));Be(!i,`The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${i&&i.name} name or alias`)}"entry"in e&&typeof window<"u"&&!e.entry.startsWith("http")&&(e.entry=new URL(e.entry,window.location.origin).href),e.shareScope||(e.shareScope=Or),e.type||(e.type=Xu)};this.hooks.lifecycle.beforeRegisterRemote.emit({remote:e,origin:n});const a=t.find(i=>i.name===e.name);if(!a)s(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n});else{const i=[`The remote "${e.name}" is already registered.`,"Please note that overriding it may cause unexpected errors."];r?.force&&(this.removeRemote(a),s(),t.push(e),this.hooks.lifecycle.registerRemote.emit({remote:e,origin:n}),fa(i.join(" ")))}}removeRemote(e){try{const{host:t}=this,{name:r}=e,n=t.options.remotes.findIndex(a=>a.name===r);n!==-1&&t.options.remotes.splice(n,1);const s=t.moduleCache.get(e.name);if(s){const a=s.remoteInfo,i=a.entryGlobalName;Ee[i]&&(Object.getOwnPropertyDescriptor(Ee,i)?.configurable?delete Ee[i]:Ee[i]=void 0);const c=kn(s.remoteInfo);Et[c]&&delete Et[c],t.snapshotHandler.manifestCache.delete(a.entry);let l=a.buildVersion?pa(a.name,a.buildVersion):a.name;const u=Ee.__FEDERATION__.__INSTANCES__.findIndex(p=>a.buildVersion?p.options.id===l:p.name===l);if(u!==-1){const p=Ee.__FEDERATION__.__INSTANCES__[u];l=p.options.id||l;const h=_a();let g=!0;const b=[];Object.keys(h).forEach(v=>{const y=h[v];y&&Object.keys(y).forEach(x=>{const k=y[x];k&&Object.keys(k).forEach(w=>{const N=k[w];N&&Object.keys(N).forEach(S=>{const M=N[S];M&&typeof M=="object"&&M.from===a.name&&(M.loaded||M.loading?(M.useIn=M.useIn.filter(P=>P!==a.name),M.useIn.length?g=!1:b.push([v,x,w,S])):b.push([v,x,w,S]))})})})}),g&&(p.shareScopeMap={},delete h[l]),b.forEach(([v,y,x,k])=>{delete h[v]?.[y]?.[x]?.[k]}),Ee.__FEDERATION__.__INSTANCES__.splice(u,1)}const{hostGlobalSnapshot:d}=Wa(e,t);if(d){const p=d&&"remotesInfo"in d&&d.remotesInfo&&Tt(d.remotesInfo,e.name).key;p&&(delete d.remotesInfo[p],Yt.__FEDERATION__.__MANIFEST_LOADING__[p]&&delete Yt.__FEDERATION__.__MANIFEST_LOADING__[p])}t.moduleCache.delete(e.name)}}catch(t){xn.error(`removeRemote failed: ${t instanceof Error?t.message:String(t)}`)}}},Md=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0,Ka=class{constructor(e){this.hooks=new _t({beforeInit:new Rt("beforeInit"),init:new Qe,beforeInitContainer:new st("beforeInitContainer"),initContainer:new st("initContainer")}),this.version="2.4.0",this.moduleCache=new Map,this.loaderHook=new _t({getModuleInfo:new Qe,createScript:new Qe,createLink:new Qe,fetch:new Ue,loadEntryError:new Ue,getModuleFactory:new Ue}),this.bridgeHook=new _t({beforeBridgeRender:new Qe,afterBridgeRender:new Qe,beforeBridgeDestroy:new Qe,afterBridgeDestroy:new Qe});const t=Md?[yd(),kd()]:[],r={id:fd(),name:e.name,plugins:t,remotes:[],shared:{},inBrowser:da};this.name=e.name,this.options=r,this.snapshotHandler=new Nd(this),this.sharedHandler=new Sd(this),this.remoteHandler=new Cd(this),this.shareScopeMap=this.sharedHandler.shareScopeMap,this.registerPlugins([...r.plugins,...e.plugins||[]]),this.options=this.formatOptions(r,e)}initOptions(e){e.name&&e.name!==this.options.name&&Ce(ya(za,ze)),this.registerPlugins(e.plugins);const t=this.formatOptions(this.options,e);return this.options=t,t}async loadShare(e,t){return this.sharedHandler.loadShare(e,t)}loadShareSync(e,t){return this.sharedHandler.loadShareSync(e,t)}initializeSharing(e=Or,t){return this.sharedHandler.initializeSharing(e,t)}initRawContainer(e,t,r){const n=_r({name:e,entry:t}),s=new Ua({host:this,remoteInfo:n});return s.remoteEntryExports=r,this.moduleCache.set(e,s),s}async loadRemote(e,t){return this.remoteHandler.loadRemote(e,t)}async preloadRemote(e){return this.remoteHandler.preloadRemote(e)}initShareScopeMap(e,t,r={}){this.sharedHandler.initShareScopeMap(e,t,r)}formatOptions(e,t){const{allShareInfos:r}=Ra(e,t),{userOptions:n,options:s}=this.hooks.lifecycle.beforeInit.emit({origin:this,userOptions:t,options:e,shareInfo:r}),a=this.remoteHandler.formatAndRegisterRemote(s,n),{allShareInfos:i}=this.sharedHandler.registerShared(s,n),c=[...s.plugins];n.plugins&&n.plugins.forEach(u=>{c.includes(u)||c.push(u)});const l={...e,...t,plugins:c,remotes:a,shared:i,id:n.id||e.id};return this.hooks.lifecycle.init.emit({origin:this,options:l}),l}registerPlugins(e){const t=md(e,this);this.options.plugins=this.options.plugins.reduce((r,n)=>(n&&r&&!r.find(s=>s.name===n.name)&&r.push(n),r),t||[])}registerRemotes(e,t){return this.remoteHandler.registerRemotes(e,t)}registerShared(e){this.sharedHandler.registerShared(this.options,{...this.options,shared:e})}};function Ed(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function Ad(e,t){const r=Ed();return Ee.__FEDERATION__.__INSTANCES__.find(n=>!!(r&&n.options.id===r||n.options.name===e&&!n.options.version&&!t||n.options.name===e&&t&&n.options.version===t))}function Pd(e){const t=new(yu()||Ka)({id:`${e.name}@${e.version||Date.now()}`,...e});return vu(t),t}var He=null;function Rd(e){const t=Ad(e.name,e.version),r={...e,id:e.id||""};return t?(t.initOptions(r),He||(He=t),t):(He=Pd(r),He)}function _d(...e){return Be(He,Yn,ze),He.loadRemote.apply(He,e)}function Id(...e){return Be(He,Yn,ze),He.registerRemotes.apply(He,e)}function Td(){return He}xu(Ka);function It(e){const t=(typeof globalThis<"u"?globalThis:void 0)?.[e];return t&&typeof t=="object"?t:{}}var Dd={singleton:!0,requiredVersion:!1,eager:!0},Ge=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:Dd}),Do="__mf_module_cache__";function Ld(){const e=globalThis,t=e[Do];if(t&&typeof t=="object"){const n=t;return n.share??={},n.remote??={},n}const r={share:{},remote:{}};return e[Do]=r,r}function Od(){const e=Ld();e.share.react??=_s,e.share["react-dom"]??=Ts,e.share["react-dom/client"]??=Ds,e.share["react/jsx-runtime"]??=Is,e.share["@tanstack/react-query"]??=Os,e.share["@trpc/client"]??=zs,e.share["@trpc/react-query"]??=Fs,e.share["react-konva"]??=Gs,e.share.konva??=Qs,e.share["@camstack/ui-library"]??=It("__camstackUiLibrary"),e.share["@camstack/sdk"]??=It("__camstackSdk"),e.share["@camstack/types"]??=It("__camstackTypes")}function $d(){Od(),Td()===null&&Rd({name:"admin_ui_host",remotes:[],shared:{react:Ge(()=>_s),"react-dom":Ge(()=>Ts),"react-dom/client":Ge(()=>Ds),"react/jsx-runtime":Ge(()=>Is),"@tanstack/react-query":Ge(()=>Os),"@trpc/client":Ge(()=>zs),"@trpc/react-query":Ge(()=>Fs),"react-konva":Ge(()=>Gs),konva:Ge(()=>Qs),"@camstack/ui-library":Ge(()=>It("__camstackUiLibrary")),"@camstack/sdk":Ge(()=>It("__camstackSdk")),"@camstack/types":Ge(()=>It("__camstackTypes"))}})}/**
|
|
37
|
+
* @license lucide-react v0.576.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/var Za=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/**
|
|
42
|
+
* @license lucide-react v0.576.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/var Bd=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
47
|
+
* @license lucide-react v0.576.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/var zd=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase());/**
|
|
52
|
+
* @license lucide-react v0.576.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/var Lo=e=>{const t=zd(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
|
|
57
|
+
* @license lucide-react v0.576.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/var Fd={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
62
|
+
* @license lucide-react v0.576.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/var Gd=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
|
|
67
|
+
* @license lucide-react v0.576.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/var Qd=De(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:i,...c},l)=>Kt("svg",{ref:l,...Fd,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Za("lucide",s),...!a&&!Gd(c)&&{"aria-hidden":"true"},...c},[...i.map(([u,d])=>Kt(u,d)),...Array.isArray(a)?a:[a]]));/**
|
|
72
|
+
* @license lucide-react v0.576.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/var I=(e,t)=>{const r=De(({className:n,...s},a)=>Kt(Qd,{ref:a,iconNode:t,className:Za(`lucide-${Bd(Lo(e))}`,`lucide-${e}`,n),...s}));return r.displayName=Lo(e),r},ot=I("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),jd=I("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),Ud=I("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Hd=I("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),Ya=I("arrow-up-to-line",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]),Vd=I("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),qd=I("battery-full",[["path",{d:"M10 10v4",key:"1mb2ec"}],["path",{d:"M14 10v4",key:"1nt88p"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 10v4",key:"1n77qd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]]),Wd=I("battery-low",[["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]]),Kd=I("battery-warning",[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 6h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2",key:"1m83kb"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"h8lgfh"}]]),Xa=I("battery",[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]]),Zd=I("bell-ring",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]),$r=I("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]),Yd=I("bug",[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]]),Xn=I("camera",[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]),Xd=I("cast",[["path",{d:"M2 8V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6",key:"3zrzxg"}],["path",{d:"M2 12a9 9 0 0 1 8 8",key:"g6cvee"}],["path",{d:"M2 16a5 5 0 0 1 4 4",key:"1y1dii"}],["line",{x1:"2",x2:"2.01",y1:"20",y2:"20",key:"xu2jvo"}]]),sr=I("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),xt=I("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),Jd=I("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),ut=I("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),$t=I("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),ep=I("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),tp=I("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),rp=I("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),np=I("circle-pause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]),op=I("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Ja=I("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),sp=I("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),ap=I("copy-plus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),dt=I("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),ip=I("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]),Jn=I("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]),lp=I("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),ei=I("door-open",[["path",{d:"M11 20H2",key:"nlcfvz"}],["path",{d:"M11 4.562v16.157a1 1 0 0 0 1.242.97L19 20V5.562a2 2 0 0 0-1.515-1.94l-4-1A2 2 0 0 0 11 4.561z",key:"au4z13"}],["path",{d:"M11 4H8a2 2 0 0 0-2 2v14",key:"74r1mk"}],["path",{d:"M14 12h.01",key:"1jfl7z"}],["path",{d:"M22 20h-3",key:"vhrsz"}]]),Nn=I("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),ti=I("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),eo=I("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),to=I("eye-off",[["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",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["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",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Bt=I("eye",[["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",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),ri=I("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]),cp=I("grip-horizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]),ni=I("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]),up=I("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),dp=I("inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]),pp=I("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),fp=I("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),oi=I("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]),Fe=I("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),mp=I("locate-fixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Oo=I("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),hp=I("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),si=I("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]),$o=I("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),ai=I("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),ro=I("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),gp=I("music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),Sn=I("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),bp=I("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Cn=I("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),zt=I("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),vp=I("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]),yp=I("power-off",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),xp=I("qr-code",[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]]),ii=I("radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]),wp=I("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),Br=I("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),li=I("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),ci=I("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),kp=I("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Np=I("scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]),Sp=I("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),er=I("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Cp=I("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),Bo=I("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),Mp=I("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),Ep=I("ship",[["path",{d:"M12 10.189V14",key:"1p8cqu"}],["path",{d:"M12 2v3",key:"qbqxhf"}],["path",{d:"M19 13V7a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2v6",key:"qpkstq"}],["path",{d:"M19.38 20A11.6 11.6 0 0 0 21 14l-8.188-3.639a2 2 0 0 0-1.624 0L3 14a11.6 11.6 0 0 0 2.81 7.76",key:"7tigtc"}],["path",{d:"M2 21c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1s1.2 1 2.5 1c2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"1924j5"}]]),Ap=I("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]),zo=I("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),Pp=I("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),ui=I("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),Rp=I("table-2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]),Fo=I("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),_p=I("thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]),Ip=I("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),et=I("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),Tp=I("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),Dp=I("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]]),Ft=I("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),Lp=I("unlink-2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]),di=I("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]),Op=I("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),pi=I("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]),no=I("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),_e=I("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Go=I("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),$p=I("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),Bp=I("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),Uv={frigate:Ep,scrypted:Mp,reolink:wp,homeAssistant:ni,rtsp:Xd},Hv={online:tp,offline:sp,degraded:$t,unknown:Ja},Qo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,jo=Ks,wt=(e,t)=>r=>{var n;if(t?.variants==null)return jo(e,r?.class,r?.className);const{variants:s,defaultVariants:a}=t,i=Object.keys(s).map(l=>{const u=r?.[l],d=a?.[l];if(u===null)return null;const p=Qo(u)||Qo(d);return s[l][p]}),c=r&&Object.entries(r).reduce((l,u)=>{let[d,p]=u;return p===void 0||(l[d]=p),l},{});return jo(e,i,t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((l,u)=>{let{class:d,className:p,...h}=u;return Object.entries(h).every(g=>{let[b,v]=g;return Array.isArray(v)?v.includes({...a,...c}[b]):{...a,...c}[b]===v})?[...l,d,p]:l},[]),r?.class,r?.className)},zp=wt("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"}}),at=De(({className:e,variant:t,size:r,...n},s)=>o("button",{ref:s,className:C(zp({variant:t,size:r}),e),...n}));at.displayName="Button";var Fp=wt("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"}}),fi=De(({className:e,variant:t,size:r,icon:n,...s},a)=>o("button",{ref:a,className:C(Fp({variant:t,size:r}),e),...s,children:o(n,{className:"h-4 w-4"})}));fi.displayName="IconButton";var Gp=wt("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"}}),gt=De(({className:e,variant:t,style:r,...n},s)=>o("span",{ref:s,className:C(Gp({variant:t,styleVariant:r}),e),...n}));gt.displayName="Badge";var Qp=wt("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),mi=De(({className:e,variant:t,...r},n)=>o("div",{ref:n,className:C(Qp({variant:t}),e),...r}));mi.displayName="Card";function jp({expanded:e,onExpandedChange:t,header:r,children:n,dimmed:s=!1,hideChevron:a=!1,className:i}){return m("div",{className:C("rounded-lg border border-border bg-surface overflow-hidden",s&&"opacity-[0.45]",i),children:[m("div",{role:"button",tabIndex:0,className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer select-none",onClick:()=>t(!e),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),t(!e))},children:[!a&&o("span",{className:"text-foreground-subtle shrink-0",children:e?o(xt,{className:"h-4 w-4"}):o(ut,{className:"h-4 w-4"})}),r]}),e&&n&&o("div",{className:"border-t border-border px-3 py-3",children:n})]})}var hi=De(({className:e,...t},r)=>o("label",{ref:r,className:C("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));hi.displayName="Label";var Up=wt("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),gi=De(({className:e,orientation:t,...r},n)=>o("div",{ref:n,role:"separator",className:C(Up({orientation:t}),e),...r}));gi.displayName="Separator";var Hp=De(({className:e,...t},r)=>o("div",{ref:r,className:C("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));Hp.displayName="Skeleton";var Uo=wt("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"}}),Mn=De(({className:e,state:t,leftSlot:r,rightSlot:n,...s},a)=>r||n?m("div",{className:"relative flex items-center w-full",children:[r&&o("div",{className:"absolute left-2.5 flex items-center pointer-events-none",children:r}),o("input",{ref:a,className:C(Uo({state:t}),r?"pl-7":"",n?"pr-7":"",e),...s}),n&&o("div",{className:"absolute right-2.5 flex items-center pointer-events-none",children:n})]}):o("input",{ref:a,className:C(Uo({state:t}),e),...s}));Mn.displayName="Input";var Ir=De(({className:e,options:t,...r},n)=>m("div",{className:"relative w-full",children:[o("select",{ref:n,className:C("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),...r,children:t.map(s=>o("option",{value:s.value,children:s.label},s.value))}),o("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted",children:o(xt,{className:"h-3.5 w-3.5"})})]}));Ir.displayName="Select";var Vp=De(({className:e,...t},r)=>o("input",{ref:r,type:"checkbox",className:C("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));Vp.displayName="Checkbox";var qp=De(({className:e,checked:t,onCheckedChange:r,label:n,...s},a)=>m("button",{ref:a,role:"switch","aria-checked":t,type:"button",onClick:()=>r(!t),className:C("inline-flex items-center gap-2",e),...s,children:[o("span",{className:C("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:o("span",{className:C("block w-3.5 h-3.5 rounded-full bg-white transition-transform",t?"translate-x-4":"translate-x-0.5")})}),n&&o("span",{className:"text-xs text-foreground",children:n})]}));qp.displayName="Switch";var bi=Je(null);function vi(){const e=Re(bi);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function Wp({children:e,open:t,onOpenChange:r}){const[n,s]=E(!1),a=t??n,i=bt(),c=R(l=>{r?.(l),t===void 0&&s(l)},[t,r]);return o(bi.Provider,{value:{open:a,setOpen:c,contentId:i},children:e})}function Vv({children:e,...t}){const{setOpen:r}=vi();return o("button",{type:"button",onClick:()=>r(!0),...t,children:e})}var Kp=wt("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"}}),yi=De(({className:e,width:t,children:r,...n},s)=>{const{open:a,setOpen:i,contentId:c}=vi(),l=W(null),u=s??l;Q(()=>{const p=u.current;p&&(a&&!p.open&&p.showModal(),!a&&p.open&&p.close())},[a,u]);const d=p=>{p.target===p.currentTarget&&i(!1)};return o("dialog",{ref:u,id:c,className:C(Kp({width:t}),"w-full",e),onClick:d,onClose:()=>i(!1),...n,children:r})});yi.displayName="DialogContent";function Zp({className:e,...t}){return o("div",{className:C("flex flex-col gap-1 mb-3",e),...t})}function Yp({className:e,...t}){return o("div",{className:C("flex justify-end gap-2 mt-4",e),...t})}function Xp({className:e,...t}){return o("h2",{className:C("text-sm font-semibold text-foreground",e),...t})}function Jp({className:e,...t}){return o("p",{className:C("text-xs text-foreground-muted",e),...t})}var xi=Je(null);function oo(){const e=Re(xi);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function qv({children:e}){const[t,r]=E(!1),n=bt(),s=bt(),a=W(null);return o(xi.Provider,{value:{open:t,setOpen:r,triggerId:n,contentId:s,triggerRef:a},children:o("div",{className:"relative inline-block",children:e})})}function Wv({children:e,...t}){const{open:r,setOpen:n,triggerId:s,contentId:a,triggerRef:i}=oo();return o("button",{type:"button",ref:i,id:s,"aria-haspopup":"menu","aria-expanded":r,"aria-controls":r?a:void 0,onClick:()=>n(!r),...t,children:e})}function Kv({className:e,children:t,align:r="start",offset:n=4,...s}){const{open:a,setOpen:i,contentId:c,triggerId:l,triggerRef:u}=oo(),d=W(null),[p,h]=E(null);return $l(()=>{if(!a){h(null);return}const g=()=>{const b=u.current;if(!b)return;const v=b.getBoundingClientRect(),y=r==="end"?v.right:v.left;h({top:v.bottom+n,left:y,minWidth:v.width})};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[a,r,n,u]),Q(()=>{if(!a)return;const g=v=>{const y=d.current,x=u.current;y&&!y.contains(v.target)&&!x?.contains(v.target)&&i(!1)},b=v=>{v.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",b)}},[a,i,u]),!a||!p||typeof document>"u"?null:Lr(o("div",{ref:d,id:c,role:"menu","aria-labelledby":l,style:{position:"fixed",top:p.top,...r==="end"?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth},className:C("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function Zv({className:e,icon:t,variant:r="default",children:n,onClick:s,...a}){const{setOpen:i}=oo(),c=R(l=>{s?.(l),i(!1)},[s,i]);return m("button",{type:"button",role:"menuitem",className:C("h-7 text-xs px-2 w-full text-left flex items-center gap-2",r==="danger"?"text-danger hover:bg-danger/10":"text-foreground hover:bg-surface-hover",e),onClick:c,...a,children:[t&&o(t,{size:14}),n]})}var wi=Je(null);function ki(){const e=Re(wi);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function Yv({children:e}){const[t,r]=E(!1),n=W(null),s=bt(),a=()=>{n.current=setTimeout(()=>r(!0),300)},i=()=>{n.current&&clearTimeout(n.current),r(!1)};return o(wi.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:o("div",{className:"relative inline-block",children:e})})}function Xv({children:e,...t}){const{show:r,hide:n,tooltipId:s,open:a}=ki();return o("div",{onMouseEnter:r,onMouseLeave:n,onFocus:r,onBlur:n,"aria-describedby":a?s:void 0,...t,children:e})}function Jv({className:e,children:t,...r}){const{open:n,tooltipId:s}=ki();return o("div",{id:s,role:"tooltip",className:C("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",n?"opacity-100":"opacity-0",e),...r,children:t})}var Ho="(max-width: 767px)",Vo="(min-width: 768px) and (max-width: 1023px)";function Ni(e){return t=>{const r=window.matchMedia(e);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)}}function Si(e){return()=>window.matchMedia(e).matches}function Ci(){return!1}function zr(){return jn(Ni(Ho),Si(Ho),Ci)}function ey(){return jn(Ni(Vo),Si(Vo),Ci)}function Mi({open:e,onClose:t,title:r,children:n,className:s}){return Q(()=>{if(!e)return;const a=i=>{i.key==="Escape"&&t()};return document.addEventListener("keydown",a),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",a),document.body.style.overflow=""}},[e,t]),m(we,{children:[o("div",{className:C("fixed inset-0 z-40 bg-black/50 transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),m("div",{role:"dialog","aria-modal":"true",className:C("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",s),children:[o("div",{className:"flex justify-center pt-2 pb-1",children:o("div",{className:"h-1 w-8 rounded-full bg-foreground-subtle/30"})}),r&&m("div",{className:"flex items-center justify-between px-4 pb-2",children:[o("span",{className:"text-sm font-medium text-foreground",children:r}),o("button",{onClick:t,className:"p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors",children:o(_e,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:n})]})]})}var Ei=Je(null);function Ai(){const e=Re(Ei);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function ef({children:e,open:t,onOpenChange:r}){const[n,s]=E(!1),a=t??n,i=bt(),c=bt(),l=R(u=>{r?.(u),t===void 0&&s(u)},[t,r]);return o(Ei.Provider,{value:{open:a,setOpen:l,triggerId:i,contentId:c},children:o("div",{className:"relative inline-block",children:e})})}function tf({children:e,...t}){const{open:r,setOpen:n,triggerId:s,contentId:a}=Ai();return o("button",{type:"button",id:s,"aria-haspopup":"dialog","aria-expanded":r,"aria-controls":r?a:void 0,onClick:()=>n(!r),...t,children:e})}function rf({className:e,children:t,...r}){const{open:n,setOpen:s,contentId:a,triggerId:i}=Ai(),c=zr(),l=W(null);return Q(()=>{if(!n||c)return;const u=p=>{const h=l.current,g=document.getElementById(i);h&&!h.contains(p.target)&&!g?.contains(p.target)&&s(!1)},d=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",d)}},[n,s,i,c]),n?c?o(Mi,{open:n,onClose:()=>s(!1),children:t}):o("div",{ref:l,id:a,role:"dialog","aria-labelledby":i,className:C("absolute left-0 top-full z-50 mt-1 bg-background-elevated border border-border rounded-lg shadow-lg p-3",e),...r,children:t}):null}var Pi=Je(null);function Ri(){const e=Re(Pi);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function ty({value:e,onValueChange:t,defaultValue:r="",className:n,...s}){const[a,i]=E(r),c=e??a,l=R(u=>{t?.(u),e===void 0&&i(u)},[e,t]);return o(Pi.Provider,{value:{value:c,setValue:l},children:o("div",{className:n,...s})})}function ry({className:e,...t}){return o("div",{role:"tablist",className:C("flex flex-row border-b border-border-subtle",e),...t})}function ny({value:e,className:t,...r}){const{value:n,setValue:s}=Ri(),a=e===n;return o("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":`tabpanel-${e}`,tabIndex:a?0:-1,className:C("h-7 text-xs px-3 transition-colors",a?"border-b-2 border-primary text-foreground font-medium":"text-foreground-muted hover:text-foreground",t),onClick:()=>s(e),...r})}function oy({value:e,className:t,...r}){const{value:n}=Ri();return e!==n?null:o("div",{role:"tabpanel",id:`tabpanel-${e}`,className:C("pt-3",t),...r})}var _i=De(({className:e,...t},r)=>o("div",{ref:r,className:C("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));_i.displayName="ScrollArea";function sy({title:e,onClose:t,children:r,defaultWidth:n=360,defaultHeight:s=280,minWidth:a=280,minHeight:i=160,offsetIndex:c=0,className:l}){const[u,d]=E({x:80+c*30,y:80+c*30}),[p,h]=E({w:n,h:s}),[g,b]=E(!1),v=W(!1),y=W(!1),x=W({x:0,y:0}),k=zr(),w=R(S=>{S.preventDefault(),v.current=!0,x.current={x:S.clientX-u.x,y:S.clientY-u.y}},[u]),N=R(S=>{S.preventDefault(),S.stopPropagation(),y.current=!0,x.current={x:S.clientX,y:S.clientY}},[]);return Q(()=>{const S=P=>{if(v.current&&d({x:P.clientX-x.current.x,y:P.clientY-x.current.y}),y.current){const A=P.clientX-x.current.x,V=P.clientY-x.current.y;x.current={x:P.clientX,y:P.clientY},h(H=>({w:Math.max(a,H.w+A),h:Math.max(i,H.h+V)}))}},M=()=>{v.current=!1,y.current=!1};return window.addEventListener("mousemove",S),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",M)}},[a,i]),k?m("div",{className:C("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",l),style:{maxHeight:"60dvh"},children:[m("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface",children:[o("span",{className:"text-[11px] font-medium truncate",children:e}),m("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>b(!g),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",children:g?o(Oo,{size:12}):o($o,{size:12})}),o("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",children:o(_e,{size:12})})]})]}),!g&&o("div",{className:"flex-1 min-h-0 overflow-y-auto",children:r})]}):m("div",{className:C("fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden",l),style:{left:u.x,top:u.y,width:g?280:p.w,height:g?"auto":p.h},children:[m("div",{onMouseDown:w,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:[m("div",{className:"flex items-center gap-2 min-w-0",children:[o(cp,{size:12,className:"text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-medium truncate",children:e})]}),m("div",{className:"flex items-center gap-1 shrink-0",children:[o("button",{onClick:()=>b(!g),className:"p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors",title:g?"Restore":"Minimize",children:g?o(Oo,{size:12}):o($o,{size:12})}),o("button",{onClick:t,className:"p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors",title:"Close",children:o(_e,{size:12})})]})]}),!g&&m("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[r,o("div",{onMouseDown:N,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 nf({open:e,onClose:t,children:r,className:n,width:s="w-64"}){const a=W(null);return Q(()=>{if(!e)return;const i=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",i),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}},[e,t]),m(we,{children:[o("div",{className:C("fixed inset-0 z-40 bg-black/50 backdrop-blur-sm transition-opacity duration-200",e?"opacity-100":"pointer-events-none opacity-0"),onClick:t,"aria-hidden":"true"}),o("div",{ref:a,role:"dialog","aria-modal":"true",className:C("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",s,e?"translate-x-0":"-translate-x-full",n),children:r})]})}function ay({items:e,className:t}){return o("nav",{className:`flex items-center gap-1 text-[11px] text-foreground-subtle ${t??""}`,children:e.map((r,n)=>{const s=n===e.length-1,a=!s&&(r.onClick||r.href);return m(Me.Fragment,{children:[n>0&&o(ut,{className:"h-3 w-3 flex-shrink-0"}),a?r.onClick?o("button",{type:"button",onClick:r.onClick,className:"hover:text-foreground transition-colors",children:r.label}):o("a",{href:r.href,className:"hover:text-foreground transition-colors",children:r.label}):o("span",{className:s?"text-foreground font-medium":"",children:r.label})]},n)})})}var qo={left:"text-left",right:"text-right",center:"text-center"};function of({columns:e,rows:t,rowKey:r,onRowClick:n,minWidthPx:s=480,emptyMessage:a,className:i,bordered:c=!0,rowClassName:l}){return t.length===0&&a?o("div",{className:`rounded-lg ${c?"border border-border":""} bg-surface px-3 py-4 text-xs text-foreground-subtle text-center ${i??""}`,children:a}):t.length===0?null:o("div",{className:`rounded-lg ${c?"border border-border":""} bg-surface overflow-x-auto ${i??""}`,children:m("table",{className:"w-full text-xs",style:{minWidth:`${s}px`},children:[o("thead",{className:"bg-surface",children:o("tr",{children:e.map(u=>{const d=u.align??"left",p=u.nowrap??!0;return o("th",{className:["px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border",qo[d],p?"whitespace-nowrap":"",u.width??""].filter(Boolean).join(" "),children:u.headerRender?u.headerRender():u.header},u.key)})})}),o("tbody",{children:t.map((u,d)=>{const p=r?r(u,d):d,h=l?.(u,d)??"",g=n!==void 0;return o("tr",{onClick:g?()=>n(u,d):void 0,className:[g?"cursor-pointer hover:bg-primary/5":"hover:bg-primary/5",h].filter(Boolean).join(" "),children:e.map(b=>{const v=b.align??"left",y=b.nowrap??!1;return o("td",{className:["px-3 py-2 text-foreground border-b border-border",qo[v],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(u,d)},b.key)})},p)})})]})})}function iy({open:e,onClose:t,title:r,subtitle:n,footer:s,children:a,widthClass:i="w-[360px]"}){return Q(()=>{if(!e)return;const c=l=>{l.key==="Escape"&&t()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[e,t]),e?m("aside",{className:C("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:[m("header",{className:"flex items-start justify-between gap-2 px-4 py-3 border-b border-border",children:[m("div",{className:"min-w-0",children:[o("div",{className:"text-sm font-semibold text-foreground truncate",children:r}),n!==void 0&&o("div",{className:"text-[11px] text-foreground-subtle mt-0.5 truncate",children:n})]}),o("button",{type:"button",onClick:t,className:"p-1 rounded hover:bg-muted text-foreground-subtle hover:text-foreground","aria-label":"Close panel",children:o(_e,{className:"w-4 h-4"})})]}),o("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3",children:a}),s!==void 0&&o("footer",{className:"flex items-center gap-2 justify-end px-4 py-3 border-t border-border",children:s})]}):null}var sf={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function Ii({node:e,depth:t,selectedAddonId:r,onSelect:n,agentDots:s}){const a=e.addonId===r,i=s?.[e.addonId]??[];return m("div",{children:[m("button",{type:"button",onClick:()=>n(e.addonId),className:C("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+t*14}px`},children:[o("span",{className:"truncate",children:e.addonName}),i.length>0&&o("span",{className:"flex items-center gap-1 shrink-0",children:i.map(c=>o("span",{title:`${c.agentNodeId}: ${c.state}`,className:C("w-2 h-2 rounded-full",sf[c.state])},c.agentNodeId))})]}),e.children.map(c=>o(Ii,{node:c,depth:t+1,selectedAddonId:r,onSelect:n,agentDots:s},c.addonId))]})}function ly({tree:e,selectedAddonId:t,onSelect:r,agentDots:n,className:s}){return o("div",{className:C("flex flex-col py-2",s),children:e.map(a=>o(Ii,{node:a,depth:0,selectedAddonId:t,onSelect:r,agentDots:n},a.addonId))})}function cy(e){const t=[],r=[],n=new Map;for(const a of e.slots)for(const i of a.addons){const c={addonId:i.id,addonName:i.name,slot:i.slot,inputClasses:i.inputClasses,outputClasses:i.outputClasses,children:[]};i.slot==="audio-classifier"?t.push(c):(r.push(c),n.set(i.id,c))}const s=[];for(const a of r){if(a.inputClasses.length===0){s.push(a);continue}const i=r.find(c=>c.addonId!==a.addonId&&c.outputClasses.some(l=>a.inputClasses.includes(l)));i&&i.children.push(a)}return[...s,...t]}function af(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function Jr({step:e,schema:t,allSchemas:r,depth:n=0,onChange:s,onDelete:a,readOnly:i=!1,toggleMode:c="simple",overrideState:l=null,onOverrideChange:u,inheritedEnabled:d,hideModelAndSettings:p=!1}){const[h,g]=E(!1),b=af(t);if(b.length>0&&!b.some(y=>y.id===e.modelId)&&!i){const y=(t?.defaultModelId?b.find(x=>x.id===t.defaultModelId):null)??b[0];y&&y.id!==e.modelId&&queueMicrotask(()=>s({...e,modelId:y.id}))}const v=m(we,{children:[m("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none",children:e.slot}),o("span",{className:"text-sm font-semibold text-foreground truncate block leading-tight",children:e.addonName}),m("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(y=>o("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400",children:y},y)),e.inputClasses.length>0&&e.outputClasses.length>0&&o("span",{className:"text-foreground-subtle/40 text-[10px]",children:"→"}),e.outputClasses.map(y=>o("span",{className:"text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400",children:y},y))]})]}),!i&&c==="simple"&&o("button",{onClick:y=>{y.stopPropagation(),s({...e,enabled:!e.enabled})},className:C("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e.enabled?"bg-success":"bg-foreground-subtle/30"),children:o("span",{className:C("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e.enabled?"translate-x-6":"translate-x-1")})}),!i&&c==="threeState"&&u&&m("div",{className:"flex items-center gap-0.5 rounded-md border border-border p-0.5",onClick:y=>y.stopPropagation(),children:[o(en,{label:"Inherit",active:l===null,variant:"inherit",subtext:d===void 0?void 0:d?"on":"off",onClick:()=>u(null)}),o(en,{label:"On",active:l===!0,variant:"on",onClick:()=>u(!0)}),o(en,{label:"Off",active:l===!1,variant:"off",onClick:()=>u(!1)})]})]});return o(jp,{expanded:h,onExpandedChange:g,dimmed:!e.enabled,header:v,children:p?o("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."}):m("div",{className:"space-y-3",children:[o(En,{label:"Model",value:e.modelId,disabled:i,options:b.map(y=>({value:y.id,label:y.name})),onChange:y=>s({...e,modelId:y})}),e.slot==="audio-classifier"&&e.engine&&o(En,{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:y=>{const[x,k]=y.split("/");s({...e,engine:{runtime:x,backend:k,format:k==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(y=>o(so,{field:y,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},y.key))]})})}function En({label:e,value:t,options:r,disabled:n,onChange:s}){return m("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e}),m("select",{value:t,onChange:a=>s(a.target.value),disabled:n,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:[r.length===0&&o("option",{value:t,children:t||"default"}),r.map(a=>o("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]})]})}function lf({label:e,description:t,value:r,options:n,disabled:s,onChange:a}){function i(c){s||a(r.includes(c)?r.filter(l=>l!==c):[...r,c])}return m("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1",children:e}),t&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:t}),o("div",{className:"flex flex-wrap gap-1.5",children:n.map(c=>o("button",{type:"button",disabled:s,onClick:()=>i(c.value),className:C("text-[10px] font-medium px-2 py-1 rounded-md border transition-colors",r.includes(c.value)?"bg-primary/20 text-primary border-primary/40":"bg-surface text-foreground-subtle border-border hover:border-primary/30",s&&"opacity-50 cursor-not-allowed"),children:c.label},c.value))})]})}function cf(e,t,r){const n=t.settings?.[e];if(n!==void 0)return n;const s=r.find(a=>"key"in a&&a.key===e);return s&&"default"in s?s.default:void 0}function so({field:e,allFields:t,step:r,disabled:n,onChange:s}){const a=e.type!=="separator"&&e.type!=="info"?e.showWhen:void 0;if(a){const{field:c,equals:l,notEquals:u,in:d,notIn:p}=a,h=cf(c,r,t);if(l!==void 0&&h!==l||u!==void 0&&h===u||d!==void 0&&!d.includes(h)||p!==void 0&&p.includes(h))return null}function i(c){s({...r,settings:{...r.settings,[e.key]:c}})}if(e.type==="select"){const c=r.settings?.[e.key],l=typeof c=="string"?c:e.default??"";return o(En,{label:e.label,value:l,disabled:n||e.disabled,options:e.options,onChange:i})}if(e.type==="multiselect"){const c=r.settings?.[e.key],l=Array.isArray(c)?c:Array.isArray(e.default)?e.default:[];return o(lf,{label:e.label,description:e.description,value:l,options:e.options,disabled:n||e.disabled,onChange:i})}if(e.type==="slider"||e.type==="number"){const c=r.settings?.[e.key],l=typeof e.default=="number"?e.default:e.min??0,u=typeof c=="number"?c:l,d=e.min??0,p=e.max??1,h=e.step??.01,g=e.type==="slider"?e.showValue:!0,b="unit"in e?e.unit:void 0,v=e.type==="slider"?e.displayScale:void 0,y=v?u/v:u;return m("div",{children:[m("div",{className:"flex items-center justify-between mb-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle uppercase tracking-wide",children:e.label}),g&&m("span",{className:"text-xs font-medium text-foreground tabular-nums",children:[typeof y=="number"?y.toFixed(2).replace(/\.?0+$/,""):y,b?` ${b}`:""]})]}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle/60 mb-1.5",children:e.description}),o("input",{type:"range",min:d,max:p,step:h,value:u,disabled:n||e.disabled,onChange:x=>i(Number(x.target.value)),className:"w-full accent-primary h-1.5"})]})}if(e.type==="boolean"){const c=r.settings?.[e.key];return m("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:typeof c=="boolean"?c:e.default===!0,disabled:n||e.disabled,onChange:l=>i(l.target.checked),className:"h-3.5 w-3.5 accent-primary"}),o("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 c=r.settings?.[e.key],l=typeof c=="string"?c:e.default??"",u=e.type==="password"?"password":"text";return m("div",{children:[o("label",{className:"block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5",children:e.label}),e.type==="textarea"?o("textarea",{value:l,disabled:n||e.disabled,placeholder:e.placeholder,onChange:d=>i(d.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"}):o("input",{type:u,value:l,disabled:n||e.disabled,placeholder:e.placeholder,onChange:d=>i(d.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"?o("div",{className:"border-t border-border my-2"}):e.type==="info"?o("div",{className:"rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle",children:e.content}):null}function en({label:e,active:t,variant:r,subtext:n,onClick:s}){return m("button",{type:"button",onClick:s,className:C("px-2 py-1 text-[10px] font-medium rounded transition-colors",t?r==="on"?"bg-green-500/20 text-green-400":r==="off"?"bg-red-500/20 text-red-400":"bg-primary/20 text-primary":"text-foreground-subtle hover:bg-surface-hover"),children:[e,n&&t&&m("span",{className:"ml-1 opacity-60",children:["(",n,")"]})]})}function Ti(e,t){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:t.enabled,modelId:t.modelId,children:[],settings:{...t.settings}}}function uf(e,t,r){return r?{enabled:r.enabled??t.enabled,modelId:r.modelId??t.modelId,settings:r.settings??t.settings}:t}function df({addon:e,agentDefault:t,modelsForFormat:r,onChangeAgentConfig:n}){const s=a=>{n?.({...t,...a})};return m("div",{className:"space-y-4 text-xs",children:[m("label",{className:"flex items-center gap-2",children:[o("input",{type:"checkbox",checked:t.enabled,onChange:a=>s({enabled:a.target.checked})}),m("span",{children:["Enabled on this agent (",e.name,")"]})]}),m("div",{children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle mb-1",children:"Model"}),o("select",{className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs",value:t.modelId,onChange:a=>s({modelId:a.target.value}),children:r.map(a=>o("option",{value:a.id,children:a.name},a.id))})]}),(e.configSchema?.length??0)>0&&m("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),e.configSchema?.map(a=>o(so,{field:a,allFields:e.configSchema??[],step:Ti(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function pf({addon:e,agentDefault:t,agentNodeId:r,currentPatch:n,modelsForFormat:s,onChangePatch:a}){const i=uf("device",t,n),c=g=>{const b=g.enabled!==void 0||g.modelId!==void 0||g.settings!==void 0;a?.(b?g:null)},l=g=>{const{enabled:b,...v}=n??{};c(g==="inherit"?v:{...v,enabled:g==="on"})},u=g=>{const{modelId:b,...v}=n??{};c(g===void 0?v:{...v,modelId:g})},d=g=>{const{settings:b,...v}=n??{};c(g===void 0?v:{...v,settings:g})},p=n?.enabled===void 0?"inherit":n.enabled?"on":"off",h=n?.modelId!==void 0;return m("div",{className:"space-y-4 text-xs",children:[m("div",{className:"flex items-center gap-1",children:[["inherit","on","off"].map(g=>o("button",{type:"button",onClick:()=>l(g),className:C("px-3 py-1 border border-border rounded text-xs capitalize",p===g?"bg-primary text-primary-foreground border-primary":"bg-surface text-foreground hover:bg-muted"),children:g},g)),m("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["agent default: ",o("span",{className:"font-semibold",children:t.enabled?"on":"off"})]})]}),m("div",{children:[m("div",{className:"flex items-center justify-between mb-1",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Model"}),h?o("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>u(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>u(t.modelId),children:"Override"})]}),o("select",{disabled:!h,className:"w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50",value:h?n?.modelId??t.modelId:t.modelId,onChange:g=>u(g.target.value),children:s.map(g=>o("option",{value:g.id,children:g.name},g.id))}),!h&&m("div",{className:"text-[10px] text-foreground-subtle mt-1",children:["inherits from ",r]})]}),(e.configSchema?.length??0)>0&&(()=>{const g=n?.settings!==void 0;return m("div",{className:"pt-2 border-t border-border/50 space-y-3",children:[m("div",{className:"flex items-center justify-between",children:[o("div",{className:"text-[10px] uppercase tracking-widest text-foreground-subtle",children:"Settings"}),g?o("button",{type:"button",className:"text-[10px] text-foreground-subtle hover:text-foreground",onClick:()=>d(void 0),children:"Clear"}):o("button",{type:"button",className:"text-[10px] text-primary hover:underline",onClick:()=>d({...t.settings}),children:"Override"})]}),e.configSchema?.map(b=>o(so,{field:b,allFields:e.configSchema??[],step:Ti(e,i),disabled:!g,onChange:v=>d({...v.settings})},b.key)),!g&&m("div",{className:"text-[10px] text-foreground-subtle",children:["inherits from ",r]})]})})(),m("div",{className:"rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle",children:[o("div",{className:"font-semibold text-foreground mb-0.5",children:"Effective config preview"}),m("div",{className:"font-mono truncate",children:[e.id," · model: ",i.modelId," · ",i.enabled?"on":"off"]})]})]})}function uy(e){const{mode:t,addon:r,agentDefault:n,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:c,engineFormat:l}=e,u=q(()=>r.models.filter(d=>!!d.formats[l]),[r.models,l]);return t==="agent"?o(df,{addon:r,agentDefault:n,modelsForFormat:u,onChangeAgentConfig:i}):o(pf,{addon:r,agentDefault:n,agentNodeId:s,currentPatch:a,modelsForFormat:u,onChangePatch:c})}function ff(e){const t=[],r=(n,s)=>{for(const a of n)t.push({node:a,depth:s}),r(a.children,s+1)};return r(e,0),t}var Wo={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 mf({slot:e}){const t=Wo[e]??Wo.classifier;return o("span",{className:C("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}var Ko="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function hf({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:m("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[e.map(r=>o("span",{className:C(Ko,"bg-blue-500/10 text-blue-500"),children:r},`in-${r}`)),e.length>0&&t.length>0&&o("span",{className:"text-foreground-subtle/60 text-[9px]",children:"→"}),t.map(r=>o("span",{className:C(Ko,"bg-emerald-500/10 text-emerald-500"),children:r},`out-${r}`))]})}function gf({enabled:e,onChange:t,disabled:r}){return o("button",{type:"button",role:"switch","aria-checked":e,disabled:r,onClick:n=>{n.stopPropagation(),t(!e)},className:C("relative inline-flex h-3.5 w-7 shrink-0 items-center rounded-full transition-colors",e?"bg-emerald-500":"bg-foreground-subtle/30",r?"opacity-50 cursor-not-allowed":"cursor-pointer"),title:e?"Click to disable":"Click to enable",children:o("span",{className:C("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function bf(e){return e.kind==="enabled"?m("span",{className:"inline-flex items-center gap-1",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shrink-0"}),o("span",{className:"font-mono text-foreground",children:e.modelId})]}):e.kind==="disabled"?m("span",{className:"inline-flex items-center gap-1 text-foreground-subtle",children:[o("span",{className:"h-1.5 w-1.5 rounded-full border border-foreground-subtle/60 shrink-0"}),"off"]}):m("span",{className:"inline-flex items-center gap-1 text-foreground-subtle/70",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-muted shrink-0"}),"n/a"]})}function vf({node:e,depth:t,agents:r,getCellState:n,onCellClick:s,selectedCell:a,toggleProps:i}){return m(we,{children:[m("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+t*14}px`},children:[m("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:[o(mf,{slot:e.slot}),m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold truncate",children:e.addonName}),o(hf,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&o("span",{className:"pl-2 pt-0.5 shrink-0",children:o(gf,{enabled:i.enabled,onChange:i.onChange,disabled:i.disabled})})]}),r.map(c=>{const l=n(e.addonId,c.agentNodeId),u=a?.addonId===e.addonId&&a.agentNodeId===c.agentNodeId;return o("button",{type:"button",onClick:()=>s(e.addonId,c.agentNodeId),className:C("text-left px-3 py-1.5 border-b border-l border-border text-xs hover:bg-muted/40",l.kind==="enabled"&&"bg-emerald-500/5",l.kind==="na"&&"bg-muted/30",u&&"ring-2 ring-primary ring-inset"),children:bf(l)},c.agentNodeId)})]})}function dy({tree:e,agents:t,getCellState:r,onCellClick:n,selectedCell:s,onToggleEnabled:a}){const i=q(()=>ff(e),[e]),c=`minmax(320px, 1fr) repeat(${t.length}, minmax(160px, 220px))`,l=a!==void 0&&t.length===1,u=t[0]?.agentNodeId;return o("div",{className:"overflow-auto border border-border rounded",children:m("div",{className:"grid",style:{gridTemplateColumns:c},children:[o("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"}),t.map(d=>m("div",{className:"sticky top-0 z-10 bg-muted/60 px-3 py-2 border-b border-l border-border",children:[o("div",{className:"text-xs font-semibold text-foreground",children:d.agentNodeId}),o("div",{className:"text-[10px] text-foreground-subtle truncate",children:d.engineLabel})]},d.agentNodeId)),i.map(({node:d,depth:p})=>{const h=l&&u!==void 0?r(d.addonId,u):null;return o(vf,{node:d,depth:p,agents:t,getCellState:r,onCellClick:n,selectedCell:s,toggleProps:l&&h!==null?{enabled:h.kind==="enabled",onChange:g=>a?.(d.addonId,g),disabled:h.kind==="na"}:void 0},d.addonId)})]})})}var Di=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,f=Di??Hl();typeof globalThis<"u"&&!Di&&(globalThis.__camstackTrpcReact=f);var ao=ct("camstack:system",null);function yf({system:e,children:t}){return o(ao.Provider,{value:e,children:t})}function tt(){const e=Re(ao);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function py(){return Re(ao)}function Fr(e,t){const r=tt(),n=W(t);n.current=t;const[s,a]=E(r.connectionVersion);Q(()=>r.subscribeConnectionEvents((i,c)=>{i==="connected"&&a(c)}),[r]),Q(()=>r.subscribeEvent(e,i=>{n.current(i)}),[r,e,s])}function An(e){const t=W(e);return t.current=e,t}function Li(e,t){const[r,n]=E(null),s=An(t);return Fr(e,a=>{const i=a.data,c=s.current;c&&!c(i)||n(i)}),r}function fy(e,t,r){const[n,s]=E(()=>new Map),a=An(t),i=An(r);return Fr(e,c=>{const l=c.data,u=i.current;if(u&&!u(l))return;const d=a.current(l);s(p=>{const h=new Map(p);return h.set(d,l),h})}),{map:n,values:q(()=>Array.from(n.values()),[n])}}function io(){const{data:e,isLoading:t}=f.nodes.topology.useQuery(void 0,{staleTime:6e4}),r=Li("cluster.topology-snapshot")?.nodes??e;return{nodes:q(()=>{const n=[];for(const s of r??[])n.push({id:String(s.id??""),name:String(s.name??s.id??""),shortName:s.isHub?"HUB":String(s.name??s.id??""),isHub:!!s.isHub,isOnline:!!s.isOnline,localIps:s.localIps??[],addons:(s.addons??[]).map(a=>({addonId:a.id,capabilities:a.capabilities}))});return n.sort((s,a)=>s.isHub!==a.isHub?s.isHub?-1:1:s.name.localeCompare(a.name)),n},[r]),isLoading:t}}function my({selectedNodeId:e,onSelect:t,label:r="Node",hideIcon:n=!1,alwaysShow:s=!1}){const{nodes:a}=io();return!s&&a.length<=1?null:m("div",{className:"flex items-center gap-1.5",children:[!n&&o(Cp,{className:"h-3.5 w-3.5 text-foreground-subtle"}),r&&o("span",{className:"text-[10px] uppercase tracking-wider text-foreground-subtle",children:r}),o("div",{className:"flex rounded-md border border-border overflow-hidden text-[11px] font-medium",children:a.map((i,c)=>{const l=e===i.id;return o("button",{type:"button",onClick:()=>t(i.id),disabled:!i.isOnline,title:i.isOnline?i.name:`${i.name} (offline)`,className:C("px-2.5 py-1 transition-colors",l?"bg-primary/15 text-primary":"bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground",c>0&&"border-l border-border",!i.isOnline&&"opacity-50 cursor-not-allowed"),children:i.shortName},i.id)})})]})}var xf={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 hy({status:e,showDot:t=!0,showLabel:r=!0,size:n="sm",className:s}){const a=xf[e];return m("span",{className:C("inline-flex items-center gap-1.5",n==="sm"?"text-xs":"text-sm",s),children:[t&&o("span",{className:C("h-1.5 w-1.5 shrink-0 rounded-full",a.colorClass),"aria-hidden":"true"}),r&&o("span",{className:"text-foreground",children:a.label})]})}var wf={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 gy({provider:e,showLabel:t=!0,className:r}){const n=wf[e];return m("span",{className:C("inline-flex items-center gap-1.5 text-xs",r),children:[o("span",{className:C("h-1.5 w-1.5 shrink-0 rounded-sm",n.colorClass),"aria-hidden":"true"}),t&&o("span",{className:"text-foreground",children:n.label})]})}var kf={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 Nf({children:e,variant:t="neutral",mono:r,className:n}){return o("span",{className:C("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",r&&"font-mono",kf[t],n),children:e})}function by({version:e,preRelease:t,className:r}){return o(Nf,{variant:t??/-(alpha|beta|rc|dev|canary|next)/i.test(e)?"warning":"success",mono:!0,className:r,children:e})}function vy({label:e,description:t,error:r,required:n,children:s,orientation:a="vertical",className:i}){const c=a==="horizontal";return m("div",{className:C("flex gap-2",c?"flex-row items-center justify-between":"flex-col",i),children:[m("div",{className:C(c?"flex-1":""),children:[m(hi,{children:[e,n&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),t&&o("p",{className:"text-foreground-subtle text-xs mt-0.5",children:t})]}),o("div",{className:C(c?"shrink-0":""),children:s}),r&&o("p",{className:"text-danger text-xs",children:r})]})}function yy({title:e,subtitle:t,actions:r,className:n}){return m("div",{className:C("flex flex-col gap-2 mb-3 sm:flex-row sm:items-center sm:justify-between",n),children:[m("div",{children:[o("h1",{className:"text-sm font-semibold text-foreground",children:e}),t&&o("p",{className:"text-foreground-subtle text-xs",children:t})]}),r&&o("div",{className:"flex items-center gap-2 flex-wrap",children:r})]})}function Sf({icon:e,title:t,description:r,action:n,className:s}){return m("div",{className:C("flex flex-col items-center justify-center gap-3 py-12",s),children:[e&&o(e,{className:"h-12 w-12 text-foreground-subtle","aria-hidden":"true"}),m("div",{className:"flex flex-col items-center gap-1 text-center",children:[o("p",{className:"text-foreground-muted text-sm font-medium",children:t}),r&&o("p",{className:"text-foreground-subtle text-xs max-w-xs",children:r})]}),n&&o("div",{className:"mt-1",children:n})]})}var Cf={danger:{box:"border-danger/40 bg-danger/10",icon:"text-danger",title:"text-danger",message:"text-danger"},warning:{box:"border-amber-500/40 bg-amber-500/10",icon:"text-amber-600 dark:text-amber-400",title:"text-amber-700 dark:text-amber-300",message:"text-amber-700 dark:text-amber-300"}};function Mf({message:e,title:t,onRetry:r,action:n,variant:s="danger",className:a}){const i=Cf[s],c=s==="warning"?Ft:$t;return m("div",{role:"alert",className:C("flex items-start gap-2.5 rounded border px-3 py-2.5",i.box,a),children:[o(c,{className:C("h-4 w-4 mt-0.5 shrink-0",i.icon),"aria-hidden":"true"}),m("div",{className:"flex-1 min-w-0",children:[t&&o("p",{className:C("text-xs font-semibold",i.title),children:t}),o("div",{className:C("text-xs break-words",i.message,t?"mt-0.5":""),children:e})]}),n??(r&&m("button",{type:"button",onClick:r,className:C("shrink-0 inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium","border border-current/30 hover:bg-current/10 transition-colors",i.message),children:[o(Br,{className:"h-3 w-3","aria-hidden":"true"}),"Retry"]}))]})}var Oi=ct("camstack:confirm-dialog",null);function Gr(){const e=Re(Oi);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function xy({children:e}){const[t,r]=E(null),n=R(l=>new Promise(u=>{r({...l,resolve:u})}),[]),s=()=>{t?.resolve(!0),r(null)},a=()=>{t?.resolve(!1),r(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"}},c=t?i[t.variant??"default"]:i.default;return m(Oi.Provider,{value:{confirm:n},children:[e,t&&m("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[o("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:a}),m("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:l=>l.stopPropagation(),children:[m("div",{className:"px-5 pt-5 pb-4",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:t.title}),o("p",{className:"mt-2 text-xs text-foreground-subtle leading-relaxed",children:t.message})]}),m("div",{className:"flex justify-end gap-2 px-5 py-3 border-t border-border bg-surface-hover/30",children:[o("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:t.cancelLabel??"Cancel"}),o("button",{type:"button",onClick:s,className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${c.button}`,children:t.confirmLabel??"Confirm"})]})]})]})]})}function wy({value:e,label:t,trend:r,className:n}){return m(mi,{className:C("flex flex-col gap-1",n),children:[m("div",{className:"flex items-baseline gap-2",children:[o("span",{className:"text-2xl font-semibold text-foreground",children:e}),r&&m("span",{className:C("inline-flex items-center gap-0.5 text-xs font-medium",r.direction==="up"?"text-success":"text-danger"),children:[r.direction==="up"?o(Tp,{className:"h-3 w-3"}):o(Dp,{className:"h-3 w-3"}),r.value,"%"]})]}),o("span",{className:"text-xs text-foreground-muted",children:t})]})}function ky({items:e,className:t}){return o("dl",{className:C("flex flex-col",t),children:e.map(r=>m("div",{className:"flex items-center h-7",children:[o("dt",{className:"text-foreground-subtle text-xs w-1/3 shrink-0",children:r.key}),o("dd",{className:"text-foreground text-xs",children:r.value})]},r.key))})}function Ny({children:e,maxHeight:t=300,className:r}){const[n,s]=E(!1),a=R(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return m("div",{className:C("relative group",r),children:[o(_i,{style:{maxHeight:t},children:o("pre",{className:"font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle",children:o("code",{children:e})})}),o("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:o(fi,{icon:n?sr:dt,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function Sy({filters:e,values:t,onChange:r,className:n}){const s=zr(),[a,i]=E(!1),c=(u,d)=>{r({...t,[u]:d})},l=Object.values(t).filter(u=>u!==void 0&&u!=="").length;if(s){const u=e.find(p=>p.type==="search"),d=e.some(p=>p.type!=="search");return m("div",{className:C("flex items-center gap-2",n),children:[u&&o(Mn,{placeholder:u.placeholder??"Search...",value:t[u.key]??"",onChange:p=>c(u.key,p.target.value),leftSlot:o(er,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),d&&m(we,{children:[m("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:[o(Ap,{className:"h-3.5 w-3.5"}),"Filters",l>0&&o(gt,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:l})]}),o(Mi,{open:a,onClose:()=>i(!1),title:"Filters",children:o("div",{className:"flex flex-col gap-3",children:e.filter(p=>p.type!=="search").map(p=>{switch(p.type){case"select":return m("div",{children:[o("label",{className:"text-xs text-foreground-muted mb-1 block",children:p.label}),o(Ir,{options:p.options,value:t[p.key]??"",onChange:h=>c(p.key,h.target.value),className:"w-full"})]},p.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1 flex-wrap",children:p.options.map(h=>{const g=t[p.key]===h.value;return o("button",{type:"button",onClick:()=>c(p.key,g?void 0:h.value),children:o(gt,{variant:g?"info":"default",className:"cursor-pointer",children:h.label})},h.value)})},p.key);default:return null}})})})]})]})}return o("div",{className:C("flex items-center gap-2 flex-wrap",n),children:e.map(u=>{switch(u.type){case"search":return o(Mn,{placeholder:u.placeholder??"Search...",value:t[u.key]??"",onChange:d=>c(u.key,d.target.value),leftSlot:o(er,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},u.key);case"select":return o(Ir,{options:u.options,value:t[u.key]??"",onChange:d=>c(u.key,d.target.value),className:"w-36"},u.key);case"badge-toggle":return o("div",{className:"flex items-center gap-1",children:u.options.map(d=>{const p=t[u.key]===d.value;return o("button",{type:"button",onClick:()=>c(u.key,p?void 0:d.value),children:o(gt,{variant:p?"info":"default",className:"cursor-pointer",children:d.label})},d.value)})},u.key);default:return null}})})}function Zo({label:e,icon:t,href:r,badge:n,active:s=!1,className:a}){return m("a",{href:r,className:C("flex items-center gap-2 h-7 px-2 text-[11px] transition-colors",s?"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:[o(t,{className:"h-3.5 w-3.5 shrink-0"}),o("span",{className:"truncate flex-1",children:e}),n!==void 0&&o(gt,{className:"ml-auto text-[10px] px-1.5 py-0",children:n})]})}function Yo({logo:e,sections:t,footer:r,onNavigate:n,className:s}){return m("nav",{className:C("bg-surface border-r border-border h-full flex flex-col",s),children:[e&&o("div",{className:"px-3 py-2 shrink-0",children:e}),o("div",{className:"flex-1 overflow-auto px-1 py-1",children:t.map((a,i)=>m("div",{className:C(i>0?"mt-3":""),children:[a.label&&o("span",{className:"text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block",children:a.label}),o("div",{className:"flex flex-col gap-0.5",onClick:n,children:a.items.map(c=>o(Zo,{...c},c.href))})]},i))}),r&&r.length>0&&m("div",{className:"shrink-0 px-1 pb-1",children:[o(gi,{className:"mb-1"}),o("div",{className:"flex flex-col gap-0.5",onClick:n,children:r.map(a=>o(Zo,{...a},a.href))})]})]})}function Cy({sidebar:e,header:t,mobileLogo:r,mobileActions:n,children:s,className:a}){const i=zr(),[c,l]=E(!1);return m("div",{className:C("flex h-screen",a),children:[!i&&o(Yo,{...e,className:C("w-44",e.className)}),i&&o(nf,{open:c,onClose:()=>l(!1),width:"w-64",children:o(Yo,{...e,onNavigate:()=>l(!1),className:"w-full border-r-0"})}),m("div",{className:"flex flex-1 flex-col min-w-0",children:[i&&m("header",{className:"flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm",children:[o("button",{onClick:()=>l(!0),className:"p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors","aria-label":"Open menu",children:o(hp,{className:"h-5 w-5"})}),r&&o("div",{className:"flex-1 flex justify-center",children:r}),n&&o("div",{className:"shrink-0",children:n})]}),!i&&t&&m("header",{className:"flex items-center h-10 border-b border-border px-4 shrink-0",children:[t.breadcrumbs&&t.breadcrumbs.length>0&&o("nav",{className:"flex items-center gap-1 text-xs flex-1 min-w-0",children:t.breadcrumbs.map((u,d)=>{const p=d===t.breadcrumbs.length-1;return m("span",{className:"flex items-center gap-1",children:[d>0&&o(ut,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),u.href&&!p?o("a",{href:u.href,className:"text-foreground-subtle hover:text-foreground transition-colors truncate",children:u.label}):o("span",{className:"text-foreground truncate",children:u.label})]},d)})}),t.actions&&o("div",{className:"flex items-center gap-2 ml-auto shrink-0",children:t.actions})]}),o("main",{className:"flex-1 overflow-auto p-4",children:s})]})]})}var Ef={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function My({title:e,subtitle:t,status:r,selected:n,onClick:s,badges:a,actions:i,offlineAction:c,className:l}){const u=r==="offline";return m("div",{onClick:s,className:C("w-full rounded-lg border p-3 text-left transition-colors",s&&"cursor-pointer",n?"border-primary bg-primary/10":"border-border bg-surface hover:bg-surface-hover",u&&!n&&"opacity-50",l),children:[m("div",{className:"flex items-center justify-between mb-2",children:[o("span",{className:"text-sm font-medium truncate",children:e}),r&&o("span",{className:C("h-2 w-2 rounded-full shrink-0",Ef[r])})]}),t&&o("div",{className:"text-[11px] text-foreground-muted",children:t}),a&&a.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-2",children:a.map((d,p)=>{const h=C("rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5",n?"bg-primary/20":"bg-surface-hover",d.onClick&&"hover:opacity-80 transition-opacity cursor-pointer");return d.onClick?m("button",{onClick:g=>{g.stopPropagation(),d.onClick()},className:h,children:[d.icon,d.label]},p):m("span",{className:h,children:[d.icon,d.label]},p)})}),!u&&i&&i.length>0&&o("div",{className:"flex items-center gap-0.5 mt-2 -mb-1",children:i.map((d,p)=>o("button",{onClick:h=>{h.stopPropagation(),d.onClick()},className:"p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors",title:d.label,"aria-label":d.label,children:d.icon},p))}),u&&c&&o("div",{className:"mt-2",onClick:d=>d.stopPropagation(),children:c})]})}function Ey({children:e,minCardWidth:t=220,gap:r=3,className:n}){return o("div",{className:C("p-4 overflow-y-auto flex-1 content-start",n),style:{display:"grid",gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`,gap:`${r*4}px`},children:e})}var Af="capability.binding-changed";function Gt(e,t){const[r,n]=E(null);return Q(()=>{if(t===null){n(null);return}let s=!1;const a=async()=>{try{const c=await e.deviceManager.getBindings.query({deviceId:t});s||n(c)}catch{s||n(c=>c)}};a();const i=e.live?.onEvent.subscribe({category:Af},{onData:c=>{const l=c.data?.source;if(!l){a();return}l.type==="device"&&l.id===t&&a()}});return()=>{s=!0,i?.unsubscribe()}},[e,t]),q(()=>r?Kl(e,r):null,[e,r])}function $i(e){const t=R(n=>e?e.subscribe(()=>n()):()=>{},[e]),r=R(()=>e?.value,[e]);return jn(t,r,r)}function Pf(e,t,r){const n=Gt(e,t);return $i(n?r(n.state):void 0)}function ar(e){const t=Gt(e.trpc,e.deviceId),r=$i(t!==null?e.slice(t):void 0),n=t!==null?e.cap(t):void 0;return{dev:t,cap:n,slice:r,available:(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&n!==void 0&&r!==void 0}}function Ay(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}var Rf={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 _f(e){const t=Rf[e.variant??"compact"];return{showIntegrationIcon:e.showIntegrationIcon??t.showIntegrationIcon,showParentBadge:e.showParentBadge??t.showParentBadge,showSnapshot:e.showSnapshot??t.showSnapshot,showBattery:e.showBattery??t.showBattery,showStableId:e.showStableId??t.showStableId,showId:e.showId??t.showId,showSwitchToggle:e.showSwitchToggle??t.showSwitchToggle,showChildrenAccordion:e.showChildrenAccordion??t.showChildrenAccordion}}var If={siren:$r,floodlight:oi,spotlight:ui,"pir-sensor":ii,chime:gp,autotrack:Jn,nightvision:ro,"privacy-mask":to,doorbell:ei},Tf={camera:Xn,hub:Sn,nvr:Sn,light:oi,siren:$r,switch:Ip,sensor:ii,thermostat:_p,button:rp,generic:no};function Bi(e){return e.role?If[e.role]??no:Tf[e.type.toLowerCase()]??Xn}var zi={"native-snapshot":up,"two-way-audio":si,"pan-tilt-zoom":Jn,"ptz-autotrack":mp,"doorbell-button":ei,"motion-trigger":ot,"battery-operated":Xa,rebootable:ci},Fi={"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"},Df={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},Gi=new Set(["camera","hub","nvr"]);function Qi(e){return!Gi.has(e.type.toLowerCase())}function Xo(e){return e.role?!0:!Gi.has(e.type.toLowerCase())}function ji(e){return(e.features??[]).includes("motion-trigger")}function Lf(e){if(e.length<=24)return e;const t=e.lastIndexOf(":");if(t>=0&&t<e.length-4)return e.slice(t+1);const r=e.split("-");if(r.length>2){const n=r.slice(-2).join("-");if(n.length>=6)return n}return`…${e.slice(-18)}`}function Of({trpc:e,accessoryChildren:t,adoptedChildren:r,onNavigate:n}){return m("div",{className:"border-t border-border-subtle/50",children:[r.length>0&&o(Jo,{trpc:e,label:"Adopted devices",rows:r,onNavigate:n}),t.length>0&&o(Jo,{trpc:e,label:"Accessories",rows:t,onNavigate:n})]})}function Jo({trpc:e,label:t,rows:r,onNavigate:n}){return m("div",{children:[o("div",{className:"px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle",children:t}),o("ul",{children:r.map(s=>o($f,{trpc:e,child:s,onNavigate:n},s.id))})]})}function $f({trpc:e,child:t,onNavigate:r}){const n=!t.disabled,s=n&&Qi(t),a=n&&ji(t);return o("li",{children:m("div",{onClick:i=>{i.stopPropagation(),r(t.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:[o(Bi(t),{className:"h-3 w-3 text-foreground-subtle flex-shrink-0"}),o("span",{className:"text-[10.5px] text-foreground flex-1 truncate",children:t.name}),a&&o(zf,{trpc:e,deviceId:t.id,features:t.features}),s&&o(Bf,{trpc:e,deviceId:t.id}),o("span",{className:C("h-1.5 w-1.5 rounded-full flex-shrink-0",t.online?"bg-success":"bg-foreground-subtle/40"),title:t.online?"Online":"Offline"})]})})}function Bf({trpc:e,deviceId:t}){const{dev:r,cap:n,slice:s,available:a}=ar({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,c]=E(!1);if(r!==null&&!n)return null;const l=s?.on===!0,u={transform:l?"translateX(14px)":"translateX(2px)"},d=async p=>{if(p.stopPropagation(),!(i||!a||!n)){c(!0);try{await n.setState({on:!l})}finally{c(!1)}}};return o("button",{type:"button",onClick:p=>{d(p)},disabled:i||!a,className:C("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",l?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?l?"Turn off":"Turn on":"Awaiting state…","aria-pressed":l,children:o("span",{className:C("absolute h-3 w-3 rounded-full transition-all",l?"bg-success":"bg-foreground-subtle"),style:u})})}function zf({trpc:e,deviceId:t,features:r}){const{dev:n,cap:s,slice:a,available:i}=ar({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:r}),[c,l]=E(!1);if(n!==null&&!s)return null;const u=a?.enabled===!0,d=async p=>{if(p.stopPropagation(),!(c||!i||!s)){l(!0);try{await s.setMotionTrigger({enabled:!u})}finally{l(!1)}}};return o("button",{type:"button",onClick:p=>{d(p)},disabled:c||!i,className:C("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",u?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(c||!i)&&"opacity-50"),title:i?u?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":u,children:o(ot,{className:"h-2.5 w-2.5"})})}function Ui({trpc:e,device:t,flags:r}){if(t.disabled)return null;const n=t.type.toLowerCase(),s=r.showSwitchToggle&&Qi(t),a=ji(t),i=n==="hub"||n==="nvr",c=(t.features??[]).includes("rebootable"),l=i&&c;return m(we,{children:[a&&o(Gf,{trpc:e,deviceId:t.id,features:t.features}),s&&o(Ff,{trpc:e,deviceId:t.id}),l&&o(jf,{trpc:e,deviceId:t.id})]})}function Ff({trpc:e,deviceId:t}){const{dev:r,cap:n,slice:s,available:a}=ar({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,c]=E(!1);if(r!==null&&!n)return null;const l=s?.on===!0,u={transform:l?"translateX(14px)":"translateX(2px)"},d=async p=>{if(p.stopPropagation(),!(i||!a||!n)){c(!0);try{await n.setState({on:!l})}finally{c(!1)}}};return o("button",{type:"button",onClick:p=>{d(p)},disabled:i||!a,className:C("relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0",l?"bg-success/30 border-success/50":"bg-surface-hover border-border",i&&"opacity-60",!a&&"opacity-40 cursor-not-allowed"),title:a?l?"Turn off":"Turn on":"Awaiting state…","aria-pressed":l,children:o("span",{className:C("absolute h-3 w-3 rounded-full transition-all",l?"bg-success":"bg-foreground-subtle"),style:u})})}function Gf({trpc:e,deviceId:t,features:r}){const{dev:n,cap:s,slice:a,available:i}=ar({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:r}),[c,l]=E(!1);if(n!==null&&!s)return null;const u=a?.enabled===!0,d=async p=>{if(p.stopPropagation(),!(c||!i||!s)){l(!0);try{await s.setMotionTrigger({enabled:!u})}finally{l(!1)}}};return o("button",{type:"button",onClick:p=>{d(p)},disabled:c||!i,className:C("inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0",u?"text-primary bg-primary/10":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover",(c||!i)&&"opacity-50"),title:i?u?"Motion-trigger: on (click to disable)":"Motion-trigger: off (click to enable)":"Awaiting state…","aria-pressed":u,children:o(ot,{className:"h-2.5 w-2.5"})})}var tn=168,Qf=4;function jf({trpc:e,deviceId:t}){const{dev:r,cap:n}=ar({trpc:e,deviceId:t,cap:y=>y.reboot,slice:()=>{}}),s=W(null),a=W(null),[i,c]=E(null),[l,u]=E(!1),d=r!==null&&n!==void 0&&n!==null,p=i!==null,h=()=>c(null),g=()=>{const y=s.current;if(!y)return;const x=y.getBoundingClientRect(),k=x.right-tn,w=Math.max(8,Math.min(k,window.innerWidth-tn-8));c({top:x.bottom+Qf,left:w})};if(Q(()=>{if(!p)return;const y=k=>{const w=s.current,N=a.current,S=k.target;S!==null&&(w&&w.contains(S)||N&&N.contains(S)||h())},x=k=>{k.key==="Escape"&&(k.stopPropagation(),h())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",x)}},[p]),r!==null&&!n)return null;const b=y=>{y.stopPropagation(),p?h():g()},v=async()=>{if(!(l||!d||!n)){u(!0),h();try{await n.reboot({})}finally{u(!1)}}};return m(we,{children:[o("button",{ref:s,type:"button",onClick:b,disabled:l||!d,className:C("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",(l||!d)&&"opacity-50",p&&"bg-surface-hover text-foreground"),title:"More actions","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":p,children:o(ti,{className:"h-3 w-3"})}),i&&Lr(o("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:tn},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-1",onClick:y=>y.stopPropagation(),children:m("button",{type:"button",role:"menuitem",onClick:()=>{v()},disabled:l||!d,className:C("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:[o(ci,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),o("span",{children:"Reboot device"})]})}),document.body)]})}var Uf=Object.freeze([]);function Hf(e){return e==="native"?"native":"enhanced"}function Vf(e){return e.map(t=>({kind:"marker",feature:t}))}function qf(e,t){const r=new Map,n=t.entries??[];for(const a of n)r.set(a.capName,a);const s=[];for(const a of e){const i=Df[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const c=r.get(i);c&&s.push({kind:Hf(c.kind),feature:a,capName:i})}return s}function Wf(e,t,r){const[n,s]=E(null),[a,i]=E(!1),[c,l]=E(!0);return Q(()=>{if(t===null){s(null),i(!1),l(!1);return}let u=!1;l(!0),i(!1);const d=async()=>{try{const h=await e.deviceManager.getBindings.query({deviceId:t});if(u)return;s(h),l(!1)}catch{if(u)return;i(!0),l(!1)}};d();const p=e.live?.onEvent.subscribe({category:"capability.binding-changed"},{onData:h=>{const g=h.data?.source;if(!g){d();return}g.type==="device"&&g.id===t&&d()}});return()=>{u=!0,p?.unsubscribe()}},[e,t]),r.length===0?{loading:c,resolved:Uf}:c||a||!n?{loading:c,resolved:Vf(r)}:{loading:!1,resolved:qf(r,n)}}var Kf=[];function Hi({trpc:e,device:t,flags:r,accessoryCount:n,adoptedCount:s,showFeatureRow:a=!1}){const i=n+s,c=r.showChildrenAccordion&&i>0,l=t.features??Kf,u=a&&l.length>0,{resolved:d}=Wf(e,u?t.id:null,l),p=u&&d.length>0;return!c&&!p?null:m("div",{className:"flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0",children:[c&&o(Zf,{accessoryCount:n,adoptedCount:s}),p&&o(Yf,{resolved:d})]})}function Zf({accessoryCount:e,adoptedCount:t}){const r=e+t;return r===0?null:m("span",{className:"text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0",title:t>0&&e>0?`${String(t)} adopted · ${String(e)} accessor${e===1?"y":"ies"}`:t>0?`${String(t)} adopted`:`${String(e)} accessor${e===1?"y":"ies"}`,children:["+",r]})}var Vi=240,es=200;function Yf({resolved:e}){const t=W(null),[r,n]=E(null);return m("span",{ref:t,className:"relative inline-flex items-center gap-1 cursor-help",onMouseEnter:()=>{const i=t.current;if(!i)return;const c=i.getBoundingClientRect();n({top:window.innerHeight-c.bottom>=es?c.bottom+4:c.top-es-4,left:Math.max(8,Math.min(c.left,window.innerWidth-Vi-8))})},onMouseLeave:()=>n(null),children:[e.map(i=>{const c=zi[i.feature];return c?o("span",{className:"inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle",title:Fi[i.feature]??i.feature,children:o(c,{className:"h-2.5 w-2.5"})},i.feature):null}),r&&Lr(o(Xf,{resolved:e,position:r}),document.body)]})}function Xf({resolved:e,position:t}){return m("div",{style:{position:"fixed",top:t.top,left:t.left,width:Vi,pointerEvents:"none"},className:"z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2",children:[o("h5",{className:"text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5",children:"Features"}),o("ul",{className:"space-y-0.5",children:e.map(r=>o(Jf,{entry:r},r.feature))})]})}function Jf({entry:e}){const t=zi[e.feature],r=Fi[e.feature]??e.feature;return m("li",{className:"flex items-center justify-between gap-2 text-[10px]",children:[m("span",{className:"flex items-center gap-1.5 text-foreground",children:[t&&o(t,{className:"h-3 w-3 text-foreground-subtle"}),o("span",{children:r})]}),o(em,{kind:e.kind})]})}function em({kind:e}){return e==="marker"?o("span",{className:"text-[8.5px] px-1 rounded text-foreground-subtle",title:"Informational marker (no cap registered)",children:"marker"}):o("span",{className:C("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function qi({device:e,variant:t,flags:r,parent:n,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:c,onNavigateToParent:l}){const u=Bi(e);return m("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[r.showChildrenAccordion&&a?o("button",{type:"button",onClick:d=>{d.stopPropagation(),c()},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?o(xt,{className:"h-3 w-3"}):o(ut,{className:"h-3 w-3"})}):r.showChildrenAccordion?o("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,o(u,{className:C("text-foreground-subtle flex-shrink-0",t==="minimal"?"h-3 w-3":"h-3.5 w-3.5")}),m("div",{className:"flex-1 min-w-0",children:[m("div",{className:"flex items-center gap-1.5 min-w-0",children:[r.showIntegrationIcon&&s&&o("span",{className:"flex-shrink-0",children:s}),o("span",{className:C("font-semibold text-foreground truncate",t==="minimal"?"text-[10.5px]":"text-[11px]"),title:e.name,children:e.name})]}),(r.showId||r.showStableId)&&m("div",{className:"mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono truncate",title:r.showStableId?`stableId: ${e.stableId}`:void 0,children:[r.showId&&m("span",{className:"flex-shrink-0 tabular-nums",children:["#",String(e.id)]}),r.showId&&r.showStableId&&o("span",{className:"flex-shrink-0 opacity-50",children:"·"}),r.showStableId&&o("span",{className:"truncate",children:Lf(e.stableId)})]}),r.showParentBadge&&n&&m("button",{type:"button",onClick:d=>{d.stopPropagation(),l(n.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: ${n.name} (#${String(n.id)})`,children:[o(Sn,{className:"h-2.5 w-2.5 shrink-0"}),m("span",{className:"truncate",children:["Under: ",n.name]})]})]})]})}function tm(e,t){return Pf(e,t,r=>r.battery)??null}function rm(e,t){const r=Gt(e,t),n=W(!1),{data:s,isLoading:a,isFetching:i,refetch:c}=Ls({queryKey:["device",t,"snapshot"],queryFn:()=>{if(!r)throw new Error("useDeviceSnapshotImage: device proxy not ready");const d=n.current;return n.current=!1,r.snapshot?.getSnapshot({force:d})??null},enabled:r!==null&&t!==null,staleTime:1e4,gcTime:1440*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:!1}),l=s?`data:${s.contentType};base64,${s.base64}`:null;function u(){n.current=!0,c()}return{src:l,loading:a||i,refresh:u}}function nm(e){return e<=10?Kd:e<=30?Wd:e>=95?qd:Xa}function om(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function sm({status:e,variant:t="compact",className:r}){if(!e)return null;const n=nm(e.percentage),s=om(e.percentage,e.charging),a=e.charging==="solar"?ui:e.charging==="dc"?vp:null,i=e.sleeping;return m("span",{className:C("inline-flex items-center gap-1 text-[10px] font-medium",s,r),title:`Battery: ${Math.round(e.percentage)}%`+(e.charging!=="none"?` · charging (${e.charging})`:"")+(e.sleeping?" · sleeping":""),children:[o(n,{className:"h-3.5 w-3.5"}),m("span",{children:[Math.round(e.percentage),"%"]}),a&&o(a,{className:"h-3 w-3"}),i&&o(ro,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&o("span",{className:"text-foreground-subtle",children:e.charging})]})}function Wi({trpc:e,device:t,status:r,enabled:n,showStatusPills:s=!1}){const a=rm(e,n&&t.online?t.id:null),i=(t.features??[]).includes("battery-operated"),c=s&&i&&!t.disabled,l=tm(e,c?t.id:null);return!n&&!c?null:m("span",{className:"inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap",children:[c&&l&&o(sm,{status:l}),n&&o(am,{deviceName:t.name,snapshotUrl:a.src,status:r})]})}var rn=288,ts=196,nn=8;function am({deviceName:e,snapshotUrl:t,status:r}){const n=W(null),[s,a]=E(null),i=r==="offline"||r==="disabled",c=()=>{const u=n.current;if(!u)return;const d=u.getBoundingClientRect(),p=d.top,h=window.innerHeight-d.bottom,g=p<ts+nn&&h>p,b=g?d.bottom+nn:d.top-ts-nn,v=d.right-rn;a({top:b,left:Math.max(8,Math.min(v,window.innerWidth-rn-8)),placeBelow:g})},l=()=>a(null);return m(we,{children:[o("button",{ref:n,type:"button",onClick:u=>u.stopPropagation(),onMouseEnter:c,onMouseLeave:l,onFocus:c,onBlur:l,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:o(Bt,{className:"h-3.5 w-3.5"})}),s&&Lr(m("div",{style:{position:"fixed",top:s.top,left:s.left,width:rn,pointerEvents:"none"},className:"rounded-lg border border-border bg-surface shadow-lg shadow-black/30 z-[9999] overflow-hidden",children:[o("div",{className:"h-40 bg-background flex items-center justify-center",children:t&&!i?o("img",{src:t,alt:e,className:"h-full w-full object-cover"}):o("span",{className:"text-xs text-foreground-subtle",children:r==="offline"?"Offline — no snapshot":r==="disabled"?"Disabled":"No snapshot yet"})}),o("div",{className:"px-3 py-2",children:o("p",{className:"text-xs font-semibold text-foreground truncate",children:e})})]}),document.body)]})}function Ki({status:e}){const t=e==="disabled"?"bg-warning":e==="online"?"bg-success":"bg-danger",r=e==="disabled"?"Disabled":e==="online"?"Online":"Offline";return o("span",{className:C("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:r})}function Pn(e){const{trpc:t,device:r,parent:n,integrationIcon:s,onNavigate:a,className:i}=e,c=_f(e),l=e.variant??"compact",u=e.view??"card",d=!r.disabled,p=r.isCamera??r.type.toLowerCase()==="camera",h=e.children??[],g=h.filter(Xo),b=h.filter(P=>!Xo(P)),v=h.length>0,[y,x]=E(!1),k=e.expanded??y,w=e.onToggleExpand??(()=>x(P=>!P)),N=P=>{a?.(P)},S=e.indentLevel??(e.isAccessoryRow?2:0),M=d?r.online?"online":"offline":"disabled";return u==="table"?o(lm,{trpc:t,device:r,variant:l,flags:c,parent:n??null,integrationIcon:s??null,accessoryCount:g.length,adoptedCount:b.length,hasChildren:v,expanded:k,onToggleExpand:w,onNavigate:N,displayStatus:M,isCamera:p,showSnapshot:c.showSnapshot&&p,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:S,className:i}):m("div",{className:C("rounded-lg border border-border bg-surface transition-colors",!d&&"opacity-60",i),children:[m("div",{onClick:()=>N(r.id),className:C("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",l==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[o(qi,{device:r,variant:l,flags:c,parent:n??null,integrationIcon:s??null,hasChildren:v,expanded:k,onToggleExpand:w,onNavigateToParent:N}),o(Hi,{trpc:t,device:r,flags:c,accessoryCount:g.length,adoptedCount:b.length,showFeatureRow:!1}),o(Wi,{trpc:t,device:r,status:M,enabled:c.showSnapshot&&p,showStatusPills:!0}),o(Ui,{trpc:t,device:r,flags:c}),o(Ki,{status:M})]}),k&&v&&o(Of,{trpc:t,accessoryChildren:g,adoptedChildren:b,onNavigate:N})]})}var im={0:"pl-2",1:"pl-6",2:"pl-8"};function lm(e){const{trpc:t,device:r,variant:n,flags:s,parent:a,integrationIcon:i,accessoryCount:c,adoptedCount:l,hasChildren:u,expanded:d,onToggleExpand:p,onNavigate:h,displayStatus:g,isCamera:b,showSnapshot:v,isAccessoryRow:y,indentLevel:x,className:k}=e;return m("tr",{onClick:()=>h(r.id),className:C("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",y&&"bg-foreground-subtle/[0.03]",k),children:[o("td",{className:C("py-2 align-middle pr-2",im[x]),children:o(qi,{device:r,variant:n,flags:s,parent:a,integrationIcon:i,hasChildren:u,expanded:d,onToggleExpand:p,onNavigateToParent:h})}),o("td",{className:"px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:r.type}),o("td",{className:"px-2 py-2 align-middle",children:o(Hi,{trpc:t,device:r,flags:s,accessoryCount:c,adoptedCount:l,showFeatureRow:!0})}),o("td",{className:"px-2 py-2 align-middle",children:o(Wi,{trpc:t,device:r,status:g,enabled:v&&b,showStatusPills:!0})}),o("td",{className:"px-2 py-2 align-middle text-right whitespace-nowrap",children:m("span",{className:"inline-flex items-center gap-1.5",children:[o(Ui,{trpc:t,device:r,flags:s}),o(Ki,{status:g})]})})]})}function cm(e,t){const[r,n]=E(e);return Q(()=>{const s=setTimeout(()=>n(e),t);return()=>clearTimeout(s)},[e,t]),r}var um=new Set(["hub","nvr"]);function dm(e){const t=new Map;for(const s of e)t.set(s.id,s);const r=[],n=new Map;for(const s of e){const a=s.parentDeviceId;if(a==null){r.push(s);continue}const i=t.get(a);if(!i){r.push(s);continue}const c=s.role!==null&&s.role!==void 0;if(um.has(i.type)&&!c){r.push(s);continue}const l=n.get(a);l?l.push(s):n.set(a,[s])}return{topLevel:r,accessoriesByParent:n}}var rs=2;function pm(e,t){if(t<=1)return[{kind:"page",n:1}];if(t<=7){const a=[];for(let i=1;i<=t;i++)a.push({kind:"page",n:i});return a}const r=[],n=Math.max(2,e-rs),s=Math.min(t-1,e+rs);r.push({kind:"page",n:1}),n>2&&r.push({kind:"ellipsis",side:"left"});for(let a=n;a<=s;a++)r.push({kind:"page",n:a});return s<t-1&&r.push({kind:"ellipsis",side:"right"}),r.push({kind:"page",n:t}),r}function fm({currentPage:e,totalItems:t,pageSize:r,onPageChange:n,itemNoun:s="devices"}){if(t<=r)return null;const a=Math.ceil(t/r),i=(e-1)*r+1,c=Math.min(e*r,t),l=pm(e,a);return m("div",{className:"flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle",children:[m("span",{children:["Showing ",i,"–",c," of ",t," ",s]}),m("span",{className:"inline-flex items-center gap-1",children:[o("button",{type:"button","aria-label":"Previous page",disabled:e===1,onClick:()=>n(e-1),className:C("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:o(Jd,{className:"h-3 w-3"})}),l.map((u,d)=>u.kind==="ellipsis"?o("span",{className:"px-1 text-foreground-subtle/60 select-none",children:"…"},`e-${d}`):o("button",{type:"button",onClick:()=>n(u.n),className:C("inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors",u.n===e?"border-primary/40 bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),children:u.n},`p-${u.n}`)),o("button",{type:"button","aria-label":"Next page",disabled:e===a,onClick:()=>n(e+1),className:C("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:o(ut,{className:"h-3 w-3"})})]})]})}function mm({view:e,onViewChange:t,types:r,currentType:n,onTypeChange:s,addons:a,currentAddon:i,onAddonChange:c,hideAddons:l=!1}){return m("div",{className:"flex items-center gap-2 flex-wrap",children:[m("span",{className:"inline-flex border border-border rounded-md overflow-hidden",children:[o("button",{type:"button",onClick:()=>t("cards"),className:C("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:o(fp,{className:"h-3.5 w-3.5"})}),o("button",{type:"button",onClick:()=>t("table"),className:C("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:o(Rp,{className:"h-3.5 w-3.5"})})]}),r&&r.length>0&&m(we,{children:[o(ns,{children:"Type"}),o(on,{active:n===null,onClick:()=>s(null),children:"All"}),r.map(u=>o(on,{active:n===u,onClick:()=>s(n===u?null:u),children:hm(u)},u))]}),!l&&a&&a.length>0&&m(we,{children:[o(ns,{children:"Integration"}),a.map(u=>o(on,{active:i===u.id,icon:u.icon,onClick:()=>c(i===u.id?null:u.id),showClearIcon:i===u.id,children:u.name},u.id))]})]})}function ns({children:e}){return o("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function on({active:e,icon:t,onClick:r,showClearIcon:n,children:s}){return m("button",{type:"button",onClick:r,className:C("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:[t&&o("span",{className:"inline-flex items-center",children:t}),o("span",{children:s}),e&&n&&o(_e,{className:"h-2.5 w-2.5 opacity-70"})]})}function hm(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function gm({variant:e,onClearFilters:t}){return m("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o(dp,{className:"h-8 w-8 text-foreground-subtle/40 mb-3"}),o("p",{className:"text-sm font-medium text-foreground-subtle",children:e==="filtered"?"No devices match the current filters":"No devices yet"}),e==="filtered"&&t&&o("button",{type:"button",onClick:t,className:"mt-2 text-[11px] text-primary hover:underline",children:"Clear filters"})]})}function Ke(e,t){if(e==="root")return t;switch(t){case"view":return"deviceView";case"page":return"devicePage";case"type":return"deviceType";case"q":return"deviceQ";case"addon":return"deviceAddon"}}function os(e){try{const t=localStorage.getItem(`camstack:${e}:lastFilters`);if(!t)return{};const r=JSON.parse(t);return typeof r!="object"||r===null?{}:r}catch{return{}}}function bm(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function ss(e,t,r){const n=new URLSearchParams(window.location.search),s=n.get(Ke(e,"view")),a=s==="cards"||s==="table"?s:r.view??t,i=n.get(Ke(e,"page")),c=i?parseInt(i,10):1;return{view:a,page:Number.isFinite(c)&&c>=1?c:1,addon:n.get(Ke(e,"addon"))??r.addon??null,type:n.get(Ke(e,"type"))??r.type??null,q:n.get(Ke(e,"q"))??r.q??""}}function vm(e,t,r){const n=new URLSearchParams(window.location.search),s=(c,l)=>{l===null||l===""?n.delete(c):n.set(c,l)};s(Ke(e,"view"),t.view===r?null:t.view),s(Ke(e,"page"),t.page===1?null:String(t.page)),s(Ke(e,"addon"),t.addon),s(Ke(e,"type"),t.type),s(Ke(e,"q"),t.q||null);const a=n.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function ym(e){const{scope:t,defaultView:r,lsKey:n}=e,[s,a]=E(()=>ss(t,r,os(n))),i=W(s);i.current=s,Q(()=>{const l=()=>{const u=ss(t,r,os(n));i.current=u,a(u)};return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[t,r,n]);const c=R(l=>{const u=l(i.current);i.current=u,a(u),vm(t,u,r),bm(n,{view:u.view,addon:u.addon,type:u.type,q:u.q})},[t,r,n]);return{state:s,setView:R(l=>c(u=>({...u,view:l})),[c]),setPage:R(l=>c(u=>({...u,page:l})),[c]),setAddon:R(l=>c(u=>({...u,addon:l,page:1})),[c]),setType:R(l=>c(u=>({...u,type:l,page:1})),[c]),setQ:R(l=>c(u=>({...u,q:l,page:1})),[c]),clearFilters:R(()=>c(l=>({...l,addon:null,type:null,q:"",page:1})),[c])}}var xm={cards:24,table:50};function Py(e){const{devices:t,trpc:r,defaultView:n="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:c,onNavigate:l,pageSize:u=xm,urlScope:d="root",lsKey:p=d==="root"?"devices":"integrations:nested"}=e,h=ym({scope:d,defaultView:n,lsKey:p}),g=h.state.view,b=g==="cards"?u.cards:u.table,[v,y]=E(h.state.q),x=cm(v,300);Q(()=>{x!==h.state.q&&h.setQ(x)},[x]);const k=a??h.state.addon,w=q(()=>{const ne=h.state.q.toLowerCase().trim();return t.filter(se=>!(k&&se.addonId!==k||h.state.type&&se.type!==h.state.type||ne&&!se.name.toLowerCase().includes(ne)&&!se.stableId.toLowerCase().includes(ne)))},[t,k,h.state.type,h.state.q]),N=q(()=>dm(w),[w]),S=q(()=>{if(h.state.q.trim()==="")return new Set;const ne=h.state.q.toLowerCase().trim(),se=new Set;for(const[oe,J]of N.accessoriesByParent.entries())J.some(K=>K.name.toLowerCase().includes(ne)||K.stableId.toLowerCase().includes(ne))&&se.add(oe);return se},[N.accessoriesByParent,h.state.q]),M=N.topLevel.length,P=Math.max(1,Math.ceil(M/b)),A=Math.min(h.state.page,P),V=(A-1)*b,H=N.topLevel.slice(V,V+b);Q(()=>{A!==h.state.page&&h.setPage(A)},[A]),Mm();const ae=k!=null||h.state.type!==null||h.state.q!=="",pe=M===0;return m("div",{className:"flex flex-col gap-3",children:[m("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[o(mm,{view:g,onViewChange:h.setView,types:s?.types,currentType:h.state.type,onTypeChange:h.setType,addons:s?.addons,currentAddon:h.state.addon,onAddonChange:h.setAddon,hideAddons:a!==void 0}),m("div",{className:"relative",children:[o(er,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none"}),o("input",{type:"text",value:v,onChange:ne=>y(ne.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"})]})]}),pe?o(gm,{variant:ae?"filtered":"nofilter",onClearFilters:ae?h.clearFilters:void 0}):g==="cards"?o(wm,{rows:H,accessoriesByParent:N.accessoriesByParent,trpc:r,resolveIntegrationIcon:i??null,resolveParent:c??null,onNavigate:l??null}):o(Sm,{rows:H,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:S,devices:w,trpc:r,resolveIntegrationIcon:i??null,resolveParent:c??null,onNavigate:l??null}),o(fm,{currentPage:A,totalItems:M,pageSize:b,onPageChange:h.setPage}),a===void 0&&ae&&M>0&&m("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",M," of ",t.length," devices",k&&m(we,{children:[" ","· filtered by"," ",o("strong",{className:"text-primary",children:s?.addons?.find(ne=>ne.id===k)?.name??k})]})]})]})}function wm({rows:e,accessoriesByParent:t,trpc:r,resolveIntegrationIcon:n,resolveParent:s,onNavigate:a}){return o("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(i=>{const c=t.get(i.id)??[];return o(Pn,{trpc:r,device:i,view:"card",integrationIcon:n?.(i.addonId)??null,parent:i.parentDeviceId!==null?s?.(i.parentDeviceId)??null:null,children:c,onNavigate:a??void 0},i.id)})})}var km=new Set(["hub","nvr"]);function Nm(e,t){return e.parentDeviceId===null||t===null?0:km.has(t.toLowerCase())?1:0}function Sm({rows:e,accessoriesByParent:t,autoExpandedParents:r,devices:n,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:c}){const l=q(()=>{const u=new Map;for(const d of n)u.set(d.id,d.type);return u},[n]);return o("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:m("table",{className:"w-full border-collapse",children:[o("thead",{children:m("tr",{className:"border-b border-border",children:[o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle",children:"Name"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),o("th",{className:"text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-20",children:"Preview"}),o("th",{className:"text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Actions"})]})}),o("tbody",{children:e.map(u=>{const d=t.get(u.id)??[],p=d.length>0,h=r.has(u.id),g=u.parentDeviceId!==null?i?.(u.parentDeviceId)??null:null,b=u.parentDeviceId!==null?l.get(u.parentDeviceId)??null:null;return o(Cm,{parent:u,accessories:d,hasAccessories:p,forceExpanded:h,trpc:s,integrationIcon:a?.(u.addonId)??null,parentRowParent:g,indentLevel:Nm(u,b),onNavigate:c??null},u.id)})})]})})}function Cm({parent:e,accessories:t,hasAccessories:r,forceExpanded:n,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:c,onNavigate:l}){const[u,d]=E(n),p=W(n);return Q(()=>{p.current!==n&&(d(n),p.current=n)},[n]),m(we,{children:[o(Pn,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:l??void 0,showChildrenAccordion:r,expanded:u,onToggleExpand:()=>d(g=>!g),indentLevel:c}),r&&u&&t.map(g=>o(Pn,{trpc:s,device:g,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:l??void 0},g.id))]})}function Mm(){or()}function Ry({options:e,value:t,onChange:r}){return o("div",{className:"flex flex-wrap gap-2",children:e.map(n=>{const s=n.id===t;return m("button",{onClick:()=>n.available&&r(n.id),disabled:!n.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${s?"border-primary/40 bg-primary/10 text-primary":n.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:[o(ip,{className:"h-3.5 w-3.5 shrink-0"}),n.label,n.isBest&&m("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:[o(Pp,{className:"h-2.5 w-2.5"}),"Best"]}),n.platformScore!=null&&m("span",{className:"text-[10px] text-foreground-subtle/60",children:["(",n.platformScore,")"]}),o("span",{className:`h-1.5 w-1.5 rounded-full ${n.available?"bg-success":"bg-danger"}`})]},n.id)})})}function Em(e,t){const r=new Set(t.slots.flatMap(i=>i.addons.map(c=>c.id))),n=[];function s(i){if(!r.has(i.addonId))return n.push(`Addon "${i.addonId}" is no longer available — step removed`),null;const c=t.slots.flatMap(d=>d.addons).find(d=>d.id===i.addonId);let l=i.modelId;if(c&&!c.models.some(d=>d.id===l)){const d=c.defaultModelId;n.push(`Model "${l}" not available for ${i.addonId} — using "${d}"`),l=d}const u=i.children.map(d=>s(d)).filter(d=>d!==null);return{...i,modelId:l,children:u}}const a=e.map(i=>s(i)).filter(i=>i!==null);return{valid:n.length===0,steps:a,warnings:n}}function Am(e){const t=new Map;for(const r of e.slots)for(const n of r.addons)t.set(n.id,n);return t}function sn(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function an({addon:e,onClick:t}){return o("button",{type:"button",onClick:t,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:m("div",{className:"flex items-center gap-3",children:[o(op,{className:"h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0"}),m("div",{className:"flex-1 min-w-0",children:[o("span",{className:"text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate",children:e.name}),m("div",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.inputClasses.map(r=>o("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:r},r)),e.inputClasses.length>0&&e.outputClasses.length>0&&o("span",{className:"text-foreground-subtle/25 text-[10px]",children:"→"}),e.outputClasses.map(r=>o("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:r},r))]})]})]})})}function _y({schema:e,steps:t,onChange:r,templates:n,selectedTemplateId:s,onSelectTemplate:a,onSaveTemplate:i,onUpdateTemplate:c,onDeleteTemplate:l,readOnly:u=!1,excludeAddons:d=[],hideTemplates:p=!1,showOnlyEnabled:h=!1,showSlotLabels:g=!1,toggleMode:b="simple",overrides:v={},onOverrideChange:y,inheritedEnabledByAddon:x={},hideModelAndSettings:k=!1}){const w=F=>({toggleMode:b,hideModelAndSettings:k,...b==="threeState"?{overrideState:v[F]!==void 0?v[F]:null,onOverrideChange:y?O=>y(F,O):void 0,inheritedEnabled:x[F]}:{}}),N=q(()=>new Set(d),[d]),S=q(()=>Am(e),[e]),[M,P]=E([]),A=s?JSON.stringify(t)!==JSON.stringify(n.find(F=>F.id===s)?.steps):!1;function V(F){const O=F.target.value||null;if(O){const ie=n.find(_=>_.id===O);ie&&P([...Em(ie.steps,e).warnings])}else P([]);a(O)}function H(){s&&c(s,t)}function ae(){const F=window.prompt("Template name:");F?.trim()&&i(F.trim(),t)}function pe(){if(!s)return;const F=n.find(O=>O.id===s);F&&window.confirm(`Delete template "${F.name}"?`)&&l(s)}function ne(F){r(t.map(O=>O.addonId!==F.addonId?O:se(F)))}function se(F){const O=F.children.some(ie=>ie.enabled||ie.children.some(_=>_.enabled));return{...F,enabled:F.enabled||O,children:F.children.map(ie=>{const _=ie.children.some(L=>L.enabled);return{...ie,enabled:ie.enabled||_}})}}function oe(F,O){const ie=sn(O);r(t.map(_=>_.addonId!==F?_:{..._,children:[..._.children,ie]}))}function J(F){const O=new Set;for(const ie of F){O.add(ie.addonId);for(const L of ie.children)O.add(L.addonId);const _=J(ie.children);for(const L of _)O.add(L)}return O}const K=J(t);function fe(F){const O=S.get(F.addonId);if(!O)return[];const ie=e.slots.find(B=>B.id===O.slot)?.parentSlot==null,_=O.childSlots,L=new Set(F.children.map(B=>B.addonId)),G=[];for(const B of e.slots)if(_.includes(B.id))for(const te of B.addons){if(L.has(te.id)||N.has(te.id))continue;const X=te.inputClasses.length===0;X&&!ie||(X||te.inputClasses.some(Le=>F.outputClasses.includes(Le)))&&G.push(te)}return G}function Z(F){const O=h?{...F,children:F.children.filter(_=>_.enabled).map(_=>({..._,children:_.children.filter(L=>L.enabled)}))}:F,ie=h?[]:fe(O);return m("div",{className:"space-y-1.5",children:[o(Jr,{step:O,schema:S.get(O.addonId)??null,allSchemas:S,onChange:ne,onDelete:u?void 0:_=>r(t.filter(L=>L.addonId!==_)),readOnly:u,...w(O.addonId)}),(O.children.length>0||ie.length>0)&&m("div",{className:"ml-4 pl-3 border-l border-border/60 space-y-1.5",children:[g&&o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40",children:"Slot: Cropper / Classifier"}),O.children.map(_=>{const L=fe(_);return m("div",{className:"space-y-1.5",children:[o(Jr,{step:_,schema:S.get(_.addonId)??null,allSchemas:S,depth:1,onChange:G=>{ne({...O,children:O.children.map(B=>B.addonId===G.addonId?G:B)})},onDelete:u?void 0:G=>{ne({...O,children:O.children.filter(B=>B.addonId!==G)})},readOnly:u,...w(_.addonId)}),(_.children.length>0||L.length>0)&&m("div",{className:"ml-4 pl-3 border-l border-border/40 space-y-1.5",children:[g&&o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30",children:"Slot: Recognizer"}),_.children.map(G=>o(Jr,{step:G,schema:S.get(G.addonId)??null,allSchemas:S,depth:2,onChange:B=>{ne({...O,children:O.children.map(te=>te.addonId===_.addonId?{...te,children:te.children.map(X=>X.addonId===B.addonId?B:X)}:te)})},onDelete:u?void 0:B=>{ne({...O,children:O.children.map(te=>te.addonId===_.addonId?{...te,children:te.children.filter(X=>X.addonId!==B)}:te)})},readOnly:u,...w(G.addonId)},G.addonId)),!u&&L.map(G=>o(an,{addon:G,onClick:()=>{const B=sn(G);ne({...O,children:O.children.map(te=>te.addonId===_.addonId?{...te,children:[...te.children,B]}:te)})}},G.id))]})]},_.addonId)}),!u&&ie.map(_=>o(an,{addon:_,onClick:()=>oe(O.addonId,_)},_.id))]})]},O.addonId)}const D=e.slots.filter(F=>F.parentSlot===null).sort((F,O)=>F.priority-O.priority);return m("div",{className:"space-y-4",children:[!p&&o("div",{className:"rounded-lg border border-border bg-surface p-3",children:m("div",{className:"flex items-center gap-2",children:[o("div",{className:"relative flex-1 min-w-0",children:m("select",{value:s??"",onChange:V,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:[o("option",{value:"",children:"No template"}),n.map(F=>o("option",{value:F.id,children:F.name},F.id))]})}),A&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),o("button",{onClick:H,disabled:!s||u,title:"Save",className:C("p-2 rounded-lg border border-border transition-colors",s&&!u?"text-foreground-subtle hover:bg-surface-hover":"text-foreground-subtle/30 cursor-not-allowed"),children:o(kp,{className:"h-4 w-4"})}),o("button",{onClick:ae,disabled:u,title:"Save As",className:C("p-2 rounded-lg border border-border transition-colors",u?"text-foreground-subtle/30 cursor-not-allowed":"text-foreground-subtle hover:bg-surface-hover"),children:o(ap,{className:"h-4 w-4"})}),o("button",{onClick:pe,disabled:!s||u,title:"Delete",className:C("p-2 rounded-lg border border-border transition-colors",s&&!u?"text-foreground-subtle hover:text-danger":"text-foreground-subtle/30 cursor-not-allowed"),children:o(et,{className:"h-4 w-4"})})]})}),M.length>0&&m("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-400 space-y-1",children:[m("div",{className:"flex items-center justify-between",children:[o("span",{className:"font-medium",children:"Template loaded with warnings:"}),o("button",{onClick:()=>P([]),className:"text-amber-400/60 hover:text-amber-400",children:o(_e,{className:"h-3.5 w-3.5"})})]}),M.map((F,O)=>m("div",{children:["• ",F]},O))]}),D.map(F=>{const O=t.filter(B=>B.slot===F.id&&!N.has(B.addonId)),ie=h?O.filter(B=>B.enabled):O,_=h?[]:F.addons.filter(B=>!K.has(B.id)&&!N.has(B.id)),L=new Map,G=[];for(const B of ie)B.group?(L.has(B.group)||L.set(B.group,[]),L.get(B.group).push(B)):G.push(B);return m("div",{className:"space-y-2",children:[g&&m("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50",children:["Slot: ",F.label]}),G.map(B=>Z(B)),[...L.entries()].map(([B,te])=>m("div",{className:"space-y-2 rounded-lg border border-border/40 p-2",children:[o("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1",children:B}),te.map(X=>Z(X))]},B)),!u&&_.map(B=>o(an,{addon:B,onClick:()=>{r([...t,sn(B)])}},B.id))]},F.id)})]})}var fr={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"},as=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],Iy="#f59e42";function je(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(fr[e])return fr[e];if(fr[e.toLowerCase()])return fr[e.toLowerCase()];let r=0;for(let n=0;n<e.length;n++)r=r*31+(e.codePointAt(n)??0)>>>0;return as[r%as.length]??"#f59e42"}function Ty({src:e,imageWidth:t,imageHeight:r,detections:n=[],classColors:s,aspectRatio:a,className:i,placeholder:c,showConfidence:l=!0,minConfidence:u=0,borderWidth:d=2}){function p(x){return je(x,s)}const h=a??(t&&r?`${t}/${r}`:"16/9"),g=n.filter(x=>x.score>=u),b=g.filter(x=>x.kind==="first-level"),v=g.filter(x=>x.kind==="detail"),y=_m(v,x=>x.parentId??"");return o("div",{className:C("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:h},children:e?m(we,{children:[o("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),g.map((x,k)=>x.debug?.mask&&x.debug.maskWidth&&x.debug.maskHeight?o(Pm,{mask:x.debug.mask,maskWidth:x.debug.maskWidth,maskHeight:x.debug.maskHeight,bbox:x.bbox,imageWidth:t,imageHeight:r,color:p(x.macroClass)},`mask-${k}`):null),b.map(x=>{const k=y.get(x.id)??[];return o(is,{detection:x,imageWidth:t,imageHeight:r,color:p(x.macroClass),showConfidence:l,borderWidth:x.debug?.mask?1:d,children:k.map(w=>o(Rm,{child:w,parentBbox:x.bbox,color:p(w.macroClass),showConfidence:l},`child-${w.id}`))},`det-${x.id}`)}),v.filter(x=>!x.parentId||!b.some(k=>k.id===x.parentId)).map(x=>o(is,{detection:x,imageWidth:t,imageHeight:r,color:p(x.macroClass),showConfidence:l,borderWidth:d},`orphan-${x.id}`))]}):o("div",{className:"w-full h-full flex items-center justify-center text-foreground-subtle text-sm",children:c??"No image loaded"})})}function is({detection:e,imageWidth:t,imageHeight:r,color:n,showConfidence:s,borderWidth:a,children:i}){const{x:c,y:l,width:u,height:d}=e.bbox,p=m("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"2px"},children:[m("span",{className:"text-[10px] px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:n},children:[e.macroClass,s&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((h,g)=>m("span",{className:"text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:je(h.label)},children:[h.label," ",(h.score*100).toFixed(0),"%"]},`${e.id}-lbl-${g}`))]});return m("div",{className:"absolute rounded-sm",style:{left:`${c/t*100}%`,top:`${l/r*100}%`,width:`${u/t*100}%`,height:`${d/r*100}%`,borderWidth:`${a}px`,borderStyle:"solid",borderColor:n},children:[p,i]})}function Pm({mask:e,maskWidth:t,maskHeight:r,bbox:n,imageWidth:s,imageHeight:a,color:i}){const c=W(null);return Q(()=>{const l=c.current;if(!l)return;const u=l.getContext("2d");if(!u)return;const d=atob(e),p=new Uint8Array(d.length);for(let x=0;x<d.length;x++)p[x]=d.charCodeAt(x);const h=parseInt(i.slice(1,3),16),g=parseInt(i.slice(3,5),16),b=parseInt(i.slice(5,7),16);l.width=t,l.height=r;const v=u.createImageData(t,r),y=t*r;for(let x=0;x<y;x++){const k=x<p.length?p[x]:0,w=x*4;k>0&&(v.data[w]=h,v.data[w+1]=g,v.data[w+2]=b,v.data[w+3]=120)}u.putImageData(v,0,0)},[e,t,r,i]),o("canvas",{ref:c,className:"absolute pointer-events-none",style:{left:`${n.x/s*100}%`,top:`${n.y/a*100}%`,width:`${n.width/s*100}%`,height:`${n.height/a*100}%`,imageRendering:"pixelated"}})}function Rm({child:e,parentBbox:t,color:r,showConfidence:n}){if(t.width<=0||t.height<=0)return null;const s=(e.bbox.x-t.x)/t.width*100,a=(e.bbox.y-t.y)/t.height*100,i=e.bbox.width/t.width*100,c=e.bbox.height/t.height*100;return o("div",{className:"absolute rounded-sm",style:{left:`${Math.max(0,s)}%`,top:`${Math.max(0,a)}%`,width:`${Math.min(100,i)}%`,height:`${Math.min(100,c)}%`,borderWidth:"1px",borderStyle:"solid",borderColor:r},children:m("div",{className:"absolute left-0 flex flex-col items-start gap-px",style:{bottom:"100%",marginBottom:"1px"},children:[m("span",{className:"text-[9px] px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:r},children:[e.macroClass,n&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((l,u)=>m("span",{className:"text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white",style:{backgroundColor:je(l.label)},children:[l.label," ",(l.score*100).toFixed(0),"%"]},`${e.id}-lbl-${u}`))]})})}function _m(e,t){const r=new Map;for(const n of e){const s=t(n),a=r.get(s)??[];a.push(n),r.set(s,a)}return r}function Dy({detections:e,classColors:t,className:r,hiddenKeys:n,onToggleVisibility:s}){const a=t;if(e.length===0)return o("div",{className:"text-sm text-foreground-subtle italic text-center py-4",children:"No detections"});const i=e.filter(d=>d.kind==="first-level"),c=e.filter(d=>d.kind==="detail"),l=new Map;for(const d of c){if(!d.parentId)continue;const p=l.get(d.parentId)??[];p.push(d),l.set(d.parentId,p)}const u=c.filter(d=>!d.parentId||!i.some(p=>p.id===d.parentId));return m("div",{className:r,children:[m("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2",children:["Detections (",e.length,")"]}),m("div",{className:"space-y-2",children:[i.map(d=>o(ls,{detection:d,children_:l.get(d.id)??[],colors:a,hiddenKeys:n,onToggleVisibility:s},d.id)),u.map(d=>o(ls,{detection:d,children_:[],colors:a,hiddenKeys:n,onToggleVisibility:s},d.id))]})]})}function ls({detection:e,children_:t,colors:r,hiddenKeys:n,onToggleVisibility:s}){const a=je(e.macroClass,r),i=!n?.has(e.id),c=e.debug?.mask,l=e.debug?.maskWidth,u=e.debug?.maskHeight,d=e.debug?.alternateLabels;return m("div",{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${i?"":"opacity-40"}`,children:[m("div",{className:"flex justify-between items-center",children:[m("div",{className:"flex items-center gap-2",children:[s&&o("input",{type:"checkbox",checked:i,onChange:()=>s(e.id,!i),className:"h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0"}),o("span",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:a}}),o("span",{className:"text-sm font-medium text-foreground",children:e.macroClass}),e.kind==="detail"&&o("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:"detail"}),c&&l&&u&&m("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",l,"x",u]})]}),o(Dm,{confidence:e.score})]}),m("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&&o("div",{className:"flex flex-wrap gap-1 mt-1",children:e.labels.map((p,h)=>m("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{backgroundColor:je(p.label,r)+"20",color:je(p.label,r)},children:[p.label,m("span",{className:"opacity-60",children:[(p.score*100).toFixed(0),"%"]}),p.detectionId&&m("span",{className:"opacity-40 text-[8px]",children:["→ ",p.detectionId]})]},h))}),d&&Object.keys(d).length>0&&o(Tm,{alternateLabels:d,colors:r}),t.length>0&&o(Im,{items:t,colors:r,hiddenKeys:n,onToggleVisibility:s})]})}function Im({items:e,colors:t,hiddenKeys:r,onToggleVisibility:n}){return o("div",{className:"ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3",children:e.map(s=>{const a=je(s.macroClass,t),i=!r?.has(s.id),c=s.debug?.mask,l=s.debug?.maskWidth,u=s.debug?.maskHeight;return m("div",{className:`text-xs space-y-0.5 ${i?"":"opacity-40"}`,children:[m("div",{className:"flex items-center gap-1.5",children:[n&&o("input",{type:"checkbox",checked:i,onChange:()=>n(s.id,!i),className:"h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0"}),o("span",{className:"h-1.5 w-1.5 rounded-full shrink-0",style:{backgroundColor:a}}),o("span",{className:"font-medium",style:{color:a},children:s.macroClass}),m("span",{className:"text-foreground-subtle",children:[(s.score*100).toFixed(0),"%"]}),c&&l&&u&&m("span",{className:"text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary",children:["mask ",l,"x",u]})]}),s.labels.length>0&&o("div",{className:"flex flex-wrap gap-1 ml-5 mt-0.5",children:s.labels.map((d,p)=>m("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full",style:{backgroundColor:je(d.label,t)+"20",color:je(d.label,t)},children:[d.label," ",m("span",{className:"opacity-60",children:[(d.score*100).toFixed(0),"%"]})]},p))})]},s.id)})})}function Tm({alternateLabels:e,colors:t}){const[r,n]=E(!1),s=Object.keys(e);return m("div",{className:"mt-1",children:[m("button",{onClick:()=>n(a=>!a),className:"text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1",children:[o("span",{className:`transition-transform ${r?"rotate-90":""}`,children:"▶"}),"Alternates (",s.length," source",s.length!==1?"s":"",")"]}),r&&o("div",{className:"mt-1 ml-3 space-y-1.5",children:s.map(a=>{const i=e[a];return!i||i.length===0?null:m("div",{children:[o("div",{className:"text-[9px] font-medium text-foreground-subtle mb-0.5",children:a}),o("div",{className:"flex flex-wrap gap-1",children:i.map((c,l)=>m("span",{className:"inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full",style:{backgroundColor:je(a,t)+"10",color:je(a,t),opacity:Math.max(.4,c.score)},children:[c.label,m("span",{className:"opacity-60",children:[(c.score*100).toFixed(1),"%"]})]},l))})]},a)})})]})}function Dm({confidence:e}){return m("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full ${e>=.8?"bg-success/10 text-success":e>=.5?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:[(e*100).toFixed(1),"%"]})}function Ly({timings:e,totalMs:t,className:r}){const n=Object.entries(e);return n.length===0&&t===void 0?null:m("div",{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${r??""}`,children:[o("div",{className:"text-xs font-medium text-foreground-subtle uppercase tracking-wide",children:"Timings"}),m("div",{className:"space-y-1 text-xs",children:[n.map(([s,a])=>m("div",{className:"flex justify-between",children:[o("span",{className:"text-foreground-subtle",children:s}),m("span",{className:"font-mono text-foreground",children:[a.toFixed(1),"ms"]})]},s)),t!==void 0&&m("div",{className:"flex justify-between pt-1 border-t border-border font-medium text-foreground",children:[o("span",{children:"Total"}),m("span",{className:"font-mono",children:[t.toFixed(1),"ms"]})]})]})]})}function Oy({images:e,selectedFilename:t,uploadedName:r,onSelect:n,onUpload:s,className:a,accept:i="image/*",uploadLabel:c="Upload..."}){const l=()=>{const u=document.createElement("input");u.type="file",u.accept=i,u.onchange=()=>{const d=u.files?.[0];if(!d)return;const p=new FileReader;p.onload=()=>{const h=p.result,g=h.split(",")[1];g&&s(g,d.name,h)},p.readAsDataURL(d)},u.click()};return m("div",{className:`flex flex-wrap items-center gap-2 ${a??""}`,children:[e.map(u=>o("button",{onClick:()=>n(u.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${t===u.filename?"bg-primary text-primary-foreground border-primary":"bg-surface border-border text-foreground hover:border-primary/50"}`,children:u.id??u.filename.replace(/\.[^.]+$/,"")},u.filename)),o("button",{onClick:l,className:"px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors",children:c}),r&&o("span",{className:"text-xs text-foreground-subtle",children:r})]})}var mr="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 $y({runtime:e,backend:t,modelId:r,agentId:n="hub",runtimes:s,backends:a,models:i,agents:c=[],onRuntimeChange:l,onBackendChange:u,onModelChange:d,onAgentChange:p,layout:h="grid",className:g,showAgent:b=!1}){return m("div",{className:`${h==="grid"?"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4":h==="horizontal"?"flex flex-wrap items-end gap-4":"space-y-3"} ${g??""}`,children:[b&&c.length>0&&m("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Agent"}),o("select",{value:n,onChange:v=>p?.(v.target.value),className:mr,children:c.map(v=>m("option",{value:v.id,children:[v.name," (",v.status,")"]},v.id))})]}),m("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Runtime"}),o("select",{value:e,onChange:v=>l(v.target.value),className:mr,children:s.map(v=>m("option",{value:v.value,disabled:!v.available,children:[v.label,v.available?"":" (unavailable)"]},v.value))})]}),m("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Backend"}),o("select",{value:t,onChange:v=>u(v.target.value),className:mr,children:a.map(v=>m("option",{value:v.id,disabled:!v.available,children:[v.label,v.available?"":" (unavailable)"]},v.id))})]}),m("label",{className:"space-y-1",children:[o("span",{className:"text-xs font-medium text-foreground-subtle",children:"Model"}),o("select",{value:r,onChange:v=>d(v.target.value),className:mr,children:i.length===0?o("option",{value:"",children:"No compatible models"}):i.map(v=>m("option",{value:v.id,children:[v.name,v.downloaded?" ✓":""]},v.id))})]})]})}var Lm=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},Zi=class{constructor(e){this.generateIdentifier=e,this.kv=new Lm}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},Om=class extends Zi{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t=="object"?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function $m(e){if("values"in Object)return Object.values(e);const t=[];for(const r in e)e.hasOwnProperty(r)&&t.push(e[r]);return t}function Bm(e,t){const r=$m(e);if("find"in r)return r.find(t);const n=r;for(let s=0;s<n.length;s++){const a=n[s];if(t(a))return a}}function Ot(e,t){Object.entries(e).forEach(([r,n])=>t(n,r))}function Mr(e,t){return e.indexOf(t)!==-1}function cs(e,t){for(let r=0;r<e.length;r++){const n=e[r];if(t(n))return n}}var zm=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Bm(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},Fm=e=>Object.prototype.toString.call(e).slice(8,-1),Yi=e=>typeof e>"u",Gm=e=>e===null,tr=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,Rn=e=>tr(e)&&Object.keys(e).length===0,it=e=>Array.isArray(e),Qm=e=>typeof e=="string",jm=e=>typeof e=="number"&&!isNaN(e),Um=e=>typeof e=="boolean",Hm=e=>e instanceof RegExp,rr=e=>e instanceof Map,nr=e=>e instanceof Set,Xi=e=>Fm(e)==="Symbol",Vm=e=>e instanceof Date&&!isNaN(e.valueOf()),Ji=e=>e instanceof Error,us=e=>typeof e=="number"&&isNaN(e),qm=e=>Um(e)||Gm(e)||Yi(e)||jm(e)||Qm(e)||Xi(e),Wm=e=>typeof e=="bigint",Km=e=>e===1/0||e===-1/0,Zm=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),Ym=e=>e instanceof URL,_n=e=>e.replace(/\\/g,"\\\\").replace(/\./g,"\\."),ln=e=>e.map(String).map(_n).join("."),Vt=(e,t)=>{const r=[];let n="";for(let a=0;a<e.length;a++){let i=e.charAt(a);if(!t&&i==="\\"){const c=e.charAt(a+1);if(c==="\\"){n+="\\",a++;continue}else if(c!==".")throw Error("invalid path")}if(i==="\\"&&e.charAt(a+1)==="."){n+=".",a++;continue}if(i==="."){r.push(n),n="";continue}n+=i}const s=n;return r.push(s),r};function We(e,t,r,n){return{isApplicable:e,annotation:t,transform:r,untransform:n}}var el=[We(Yi,"undefined",()=>null,()=>{}),We(Wm,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):(console.error("Please add a BigInt polyfill."),e)),We(Vm,"Date",e=>e.toISOString(),e=>new Date(e)),We(Ji,"Error",(e,t)=>{const r={name:e.name,message:e.message};return"cause"in e&&(r.cause=e.cause),t.allowedErrorProps.forEach(n=>{r[n]=e[n]}),r},(e,t)=>{const r=new Error(e.message,{cause:e.cause});return r.name=e.name,r.stack=e.stack,t.allowedErrorProps.forEach(n=>{r[n]=e[n]}),r}),We(Hm,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),r=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,r)}),We(nr,"set",e=>[...e.values()],e=>new Set(e)),We(rr,"map",e=>[...e.entries()],e=>new Map(e)),We(e=>us(e)||Km(e),"number",e=>us(e)?"NaN":e>0?"Infinity":"-Infinity",Number),We(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),We(Ym,"URL",e=>e.toString(),e=>new URL(e))];function Qr(e,t,r,n){return{isApplicable:e,annotation:t,transform:r,untransform:n}}var tl=Qr((e,t)=>Xi(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,r)=>{const n=r.symbolRegistry.getValue(t[1]);if(!n)throw new Error("Trying to deserialize unknown symbol");return n}),Xm=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),rl=Qr(Zm,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const r=Xm[t[1]];if(!r)throw new Error("Trying to deserialize unknown typed array");return new r(e)});function nl(e,t){return e?.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var ol=Qr(nl,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{const r=t.classRegistry.getAllowedProps(e.constructor);if(!r)return{...e};const n={};return r.forEach(s=>{n[s]=e[s]}),n},(e,t,r)=>{const n=r.classRegistry.getValue(t[1]);if(!n)throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(n.prototype),e)}),sl=Qr((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,r)=>{const n=r.customTransformerRegistry.findByName(t[1]);if(!n)throw new Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),Jm=[ol,tl,sl,rl],ds=(e,t)=>{const r=cs(Jm,s=>s.isApplicable(e,t));if(r)return{value:r.transform(e,t),type:r.annotation(e,t)};const n=cs(el,s=>s.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},al={};el.forEach(e=>{al[e.annotation]=e});var eh=(e,t,r)=>{if(it(t))switch(t[0]){case"symbol":return tl.untransform(e,t,r);case"class":return ol.untransform(e,t,r);case"custom":return sl.untransform(e,t,r);case"typed-array":return rl.untransform(e,t,r);default:throw new Error("Unknown transformation: "+t)}else{const n=al[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,r)}},At=(e,t)=>{if(t>e.size)throw new Error("index out of bounds");const r=e.keys();for(;t>0;)r.next(),t--;return r.next().value};function il(e){if(Mr(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Mr(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Mr(e,"constructor"))throw new Error("constructor is not allowed as a property")}var th=(e,t)=>{il(t);for(let r=0;r<t.length;r++){const n=t[r];if(nr(e))e=At(e,+n);else if(rr(e)){const s=+n,a=+t[++r]==0?"key":"value",i=At(e,s);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},In=(e,t,r)=>{if(il(t),t.length===0)return r(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(it(n)){const c=+i;n=n[c]}else if(tr(n))n=n[i];else if(nr(n)){const c=+i;n=At(n,c)}else if(rr(n)){if(a===t.length-2)break;const c=+i,l=+t[++a]==0?"key":"value",u=At(n,c);switch(l){case"key":n=u;break;case"value":n=n.get(u);break}}}const s=t[t.length-1];if(it(n)?n[+s]=r(n[+s]):tr(n)&&(n[s]=r(n[s])),nr(n)){const a=At(n,+s),i=r(a);a!==i&&(n.delete(a),n.add(i))}if(rr(n)){const a=+t[t.length-2],i=At(n,a);switch(+s==0?"key":"value"){case"key":{const c=r(i);n.set(c,n.get(i)),c!==i&&n.delete(i);break}case"value":n.set(i,r(n.get(i)));break}}return e},ll=e=>e<1;function Tn(e,t,r,n=[]){if(!e)return;const s=ll(r);if(!it(e)){Ot(e,(c,l)=>Tn(c,t,r,[...n,...Vt(l,s)]));return}const[a,i]=e;i&&Ot(i,(c,l)=>{Tn(c,t,r,[...n,...Vt(l,s)])}),t(a,n)}function rh(e,t,r,n){return Tn(t,(s,a)=>{e=In(e,a,i=>eh(i,s,n))},r),e}function nh(e,t,r){const n=ll(r);function s(a,i){const c=th(e,Vt(i,n));a.map(l=>Vt(l,n)).forEach(l=>{e=In(e,l,()=>c)})}if(it(t)){const[a,i]=t;a.forEach(c=>{e=In(e,Vt(c,n),()=>e)}),i&&Ot(i,s)}else Ot(t,s);return e}var oh=(e,t)=>tr(e)||it(e)||rr(e)||nr(e)||Ji(e)||nl(e,t);function sh(e,t,r){const n=r.get(e);n?n.push(t):r.set(e,[t])}function ah(e,t){const r={};let n;return e.forEach(s=>{if(s.length<=1)return;t||(s=s.map(c=>c.map(String)).sort((c,l)=>c.length-l.length));const[a,...i]=s;a.length===0?n=i.map(ln):r[ln(a)]=i.map(ln)}),n?Rn(r)?[n]:[n,r]:Rn(r)?void 0:r}var cl=(e,t,r,n,s=[],a=[],i=new Map)=>{const c=qm(e);if(!c){sh(e,s,t);const g=i.get(e);if(g)return n?{transformedValue:null}:g}if(!oh(e,r)){const g=ds(e,r),b=g?{transformedValue:g.value,annotations:[g.type]}:{transformedValue:e};return c||i.set(e,b),b}if(Mr(a,e))return{transformedValue:null};const l=ds(e,r),u=l?.value??e,d=it(u)?[]:{},p={};Ot(u,(g,b)=>{if(b==="__proto__"||b==="constructor"||b==="prototype")throw new Error(`Detected property ${b}. This is a prototype pollution risk, please remove it from your object.`);const v=cl(g,t,r,n,[...s,b],[...a,e],i);d[b]=v.transformedValue,it(v.annotations)?p[_n(b)]=v.annotations:tr(v.annotations)&&Ot(v.annotations,(y,x)=>{p[_n(b)+"."+x]=y})});const h=Rn(p)?{transformedValue:d,annotations:l?[l.type]:void 0}:{transformedValue:d,annotations:l?[l.type,p]:p};return c||i.set(e,h),h};function ul(e){return Object.prototype.toString.call(e).slice(8,-1)}function ps(e){return ul(e)==="Array"}function ih(e){if(ul(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function lh(e,t,r,n,s){const a={}.propertyIsEnumerable.call(n,t)?"enumerable":"nonenumerable";a==="enumerable"&&(e[t]=r),s&&a==="nonenumerable"&&Object.defineProperty(e,t,{value:r,enumerable:!1,writable:!0,configurable:!0})}function Dn(e,t={}){if(ps(e))return e.map(s=>Dn(s,t));if(!ih(e))return e;const r=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...r,...n].reduce((s,a)=>{if(a==="__proto__"||ps(t.props)&&!t.props.includes(a))return s;const i=e[a];return lh(s,a,Dn(i,t),e,t.nonenumerable),s},{})}var de=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Om,this.symbolRegistry=new Zi(t=>t.description??""),this.customTransformerRegistry=new zm,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,r=cl(e,t,this,this.dedupe),n={json:r.transformedValue};r.annotations&&(n.meta={...n.meta,values:r.annotations});const s=ah(t,this.dedupe);return s&&(n.meta={...n.meta,referentialEqualities:s}),n.meta&&(n.meta.v=1),n}deserialize(e,t){const{json:r,meta:n}=e;let s=t?.inPlace?r:Dn(r);return n?.values&&(s=rh(s,n.values,n.v??0,this)),n?.referentialEqualities&&(s=nh(s,n.referentialEqualities,n.v??0)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e),{inPlace:!0})}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};de.defaultInstance=new de;de.serialize=de.defaultInstance.serialize.bind(de.defaultInstance);de.deserialize=de.defaultInstance.deserialize.bind(de.defaultInstance);de.stringify=de.defaultInstance.stringify.bind(de.defaultInstance);de.parse=de.defaultInstance.parse.bind(de.defaultInstance);de.registerClass=de.defaultInstance.registerClass.bind(de.defaultInstance);de.registerSymbol=de.defaultInstance.registerSymbol.bind(de.defaultInstance);de.registerCustom=de.defaultInstance.registerCustom.bind(de.defaultInstance);de.allowErrorProps=de.defaultInstance.allowErrorProps.bind(de.defaultInstance);de.serialize;de.deserialize;de.stringify;de.parse;de.registerClass;de.registerCustom;de.registerSymbol;de.allowErrorProps;function ch({className:e}){return m("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:[o("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"}),o("circle",{cx:"12",cy:"12",r:"3"})]})}function uh({className:e}){return m("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:[o("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"}),o("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),o("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"}),o("path",{d:"m2 2 20 20"})]})}function dh({className:e}){return o("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:o("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function ph({onLogin:e,serverUrl:t,logoSrc:r,error:n,className:s}){const[a,i]=E(""),[c,l]=E(""),[u,d]=E(!1),[p,h]=E(!1),[g,b]=E(null),v=n??g,y=async x=>{if(x.preventDefault(),!p){b(null),h(!0);try{await e(a,c)}catch(k){b(k instanceof Error?k.message:"Login failed. Please try again.")}finally{h(!1)}}};return o("div",{className:C("flex min-h-screen items-center justify-center bg-background p-4",s),children:m("div",{className:"w-full max-w-sm",children:[r&&o("div",{className:"flex justify-center mb-8",children:o("img",{src:r,alt:"Logo",className:"h-12"})}),t&&o("p",{className:"mb-4 text-center text-xs text-foreground-subtle truncate",children:t}),m("form",{onSubmit:y,className:"space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10",children:[v&&o("div",{className:"rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger",children:v}),m("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Username"}),o("input",{type:"text",value:a,onChange:x=>i(x.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"})]}),m("div",{className:"space-y-1.5",children:[o("label",{className:"text-xs font-medium text-foreground-subtle",children:"Password"}),m("div",{className:"relative",children:[o("input",{type:u?"text":"password",value:c,onChange:x=>l(x.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"}),o("button",{type:"button",onClick:()=>d(x=>!x),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,children:u?o(uh,{className:"h-4 w-4"}):o(ch,{className:"h-4 w-4"})})]})]}),m("button",{type:"submit",disabled:p,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:[p&&o(dh,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}var Ln="camstack_dev_token",dl=Je(null);function By(){const e=Re(dl);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function fh(){return typeof window>"u"?null:localStorage.getItem(Ln)}function mh({className:e}){return m("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:[o("circle",{cx:"12",cy:"12",r:"4"}),o("path",{d:"M12 2v2"}),o("path",{d:"M12 20v2"}),o("path",{d:"m4.93 4.93 1.41 1.41"}),o("path",{d:"m17.66 17.66 1.41 1.41"}),o("path",{d:"M2 12h2"}),o("path",{d:"M20 12h2"}),o("path",{d:"m6.34 17.66-1.41 1.41"}),o("path",{d:"m19.07 4.93-1.41 1.41"})]})}function hh({className:e}){return o("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:o("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function gh({children:e,serverUrl:t,title:r,token:n,onLogout:s}){const a=ac(),i=q(()=>[Ql({condition:h=>h.type==="subscription",true:jl({client:Ul({url:t.replace(/^http/,"ws")+"/trpc",connectionParams:()=>({token:n})}),transformer:de}),false:Bs({url:`${t}/trpc`,transformer:de,headers:()=>({authorization:`Bearer ${n}`})})})],[t,n]),c=q(()=>$s({links:i}),[i]),l=q(()=>f.createClient({links:i}),[i]),u=q(()=>Yl({serverUrl:t,token:n}),[t,n]);Q(()=>(u.init().catch(()=>{}),()=>{u.close()}),[u]);const d=q(()=>new Fl,[]),p=q(()=>({trpc:c,token:n,logout:s}),[c,n,s]);return o(yf,{system:u,children:o(f.Provider,{client:l,queryClient:d,children:o(Gl,{client:d,children:o(dl.Provider,{value:p,children:m("div",{className:"min-h-screen bg-background text-foreground",children:[m("div",{className:"flex items-center justify-between border-b border-border bg-surface px-4 py-2",children:[m("div",{className:"flex items-center gap-2",children:[o("span",{className:"rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning",children:"DEV MODE"}),r&&o("span",{className:"text-sm font-medium text-foreground",children:r}),o("span",{className:"text-xs text-foreground-subtle",children:t})]}),m("div",{className:"flex items-center gap-2",children:[m("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"?o(mh,{className:"h-3.5 w-3.5"}):o(hh,{className:"h-3.5 w-3.5"}),a.mode==="dark"?"Dark":a.mode==="light"?"Light":"System"]}),o("button",{type:"button",onClick:s,className:"rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors",children:"Logout"})]})]}),o("div",{className:"p-4",children:e({trpc:c,theme:a})})]})})})})})}function bh({children:e,serverUrl:t="https://localhost:4443",title:r}){const[n,s]=E(fh),a=R(async(c,l)=>{const u=await $s({links:[Bs({url:`${t}/trpc`,transformer:de})]}).auth.login.mutate({username:c,password:l});if(!u.token)throw new Error("No token returned");localStorage.setItem(Ln,u.token),s(u.token)},[t]),i=R(()=>{localStorage.removeItem(Ln),s(null)},[]);return n?o(vo,{children:o(gh,{serverUrl:t,title:r,token:n,onLogout:i,children:e})}):o(vo,{children:o(ph,{onLogin:a,serverUrl:t})})}function zy(e,t={}){const{serverUrl:r="https://localhost:4443",title:n,rootId:s="root"}=t,a=document.getElementById(s);if(!a){console.error(`[mountAddonPage] Element #${s} not found`);return}Bl(a).render(Kt(bh,{serverUrl:r,title:n,children:({trpc:i,theme:c})=>Kt(e,{trpc:i,theme:{isDark:c.resolvedMode==="dark"},navigate:l=>{console.log("[dev] navigate:",l)}})}))}var pl=ct("camstack:custom-field-renderers",{});function Fy({renderers:e,children:t}){return o(pl.Provider,{value:e,children:t})}function vh(e){return Re(pl)[e]??null}var lo=ct("camstack:device-context",null);function Gy({deviceId:e,device:t,children:r}){const n={deviceId:e,device:t??null};return o(lo.Provider,{value:n,children:r})}function yh(){return Re(lo)?.deviceId??null}function Qy(){return Re(lo)?.device??null}var jy=f.accessories.getStatus.useQuery,Uy=f.addonPages.listPages.useQuery,xh=f.addons.list.useQuery,Hy=f.addons.getLogs.useQuery,Vy=f.addons.listPackages.useQuery,qy=f.addons.installPackage.useMutation,Wy=f.addons.installFromWorkspace.useMutation,Ky=f.addons.isWorkspaceAvailable.useQuery,Zy=f.addons.listWorkspacePackages.useQuery,Yy=f.addons.uninstallPackage.useMutation,Xy=f.addons.reloadPackages.useMutation,Jy=f.addons.searchAvailable.useQuery,e0=f.addons.listUpdates.useQuery,t0=f.addons.updatePackage.useMutation,r0=f.addons.rollbackPackage.useMutation,n0=f.addons.forceRefresh.useMutation,o0=f.addons.restartServer.useMutation,s0=f.addons.getLastRestart.useQuery,a0=f.addons.listFrameworkPackages.useQuery,i0=f.addons.listCapabilityProviders.useQuery,l0=f.addons.setCapabilityProviderEnabled.useMutation,c0=f.addons.updateFrameworkPackage.useMutation,u0=f.addons.getVersions.useQuery,d0=f.addons.restartAddon.useMutation,p0=f.addons.retryLoad.useMutation,f0=f.addons.getAutoUpdateSettings.useQuery,m0=f.addons.setAutoUpdateSettings.useMutation,h0=f.addons.getAddonAutoUpdate.useQuery,g0=f.addons.setAddonAutoUpdate.useMutation,b0=f.addons.applyAutoUpdateToAll.useMutation,v0=f.addons.custom.useMutation,y0=f.addons.onAddonLogs.useSubscription,x0=f.addonSettings.getGlobalSettings.useQuery,w0=f.addonSettings.updateGlobalSettings.useMutation,k0=f.addonSettings.getDeviceSettings.useQuery,N0=f.addonSettings.updateDeviceSettings.useMutation,wh=f.addonWidgets.listWidgets.useQuery,S0=f.alerts.emit.useMutation,C0=f.alerts.update.useMutation,M0=f.alerts.list.useQuery,E0=f.alerts.getUnreadCount.useQuery,A0=f.alerts.markRead.useMutation,P0=f.alerts.markAllRead.useMutation,R0=f.alerts.dismiss.useMutation,_0=f.audioAnalysis.resolveDeviceSettings.useQuery,I0=f.audioAnalysis.getDeviceSettingsContribution.useQuery,T0=f.audioAnalysis.getDeviceLiveContribution.useQuery,D0=f.audioAnalysis.applyDeviceSettingsPatch.useMutation,L0=f.audioAnalyzer.analyseChunk.useMutation,O0=f.audioAnalyzer.classify.useQuery,$0=f.audioAnalyzer.isReady.useQuery,B0=f.audioAnalyzer.dispose.useMutation,z0=f.audioAnalyzer.reprobeAudioEngine.useMutation,F0=f.audioCodec.listSupportedCodecs.useQuery,G0=f.audioCodec.canHandle.useQuery,Q0=f.audioCodec.createDecodeSession.useMutation,j0=f.audioCodec.createEncodeSession.useMutation,U0=f.audioCodec.closeSession.useMutation,H0=f.audioCodec.pushEncodedFrame.useMutation,V0=f.audioCodec.pullPcm.useQuery,q0=f.audioCodec.pushPcm.useMutation,W0=f.audioCodec.pullEncoded.useQuery,K0=f.audioCodec.flushEncode.useMutation,Z0=f.audioCodec.listActiveSessions.useQuery,Y0=f.audioMetrics.getCurrentSnapshot.useQuery,X0=f.audioMetrics.getHistory.useQuery,J0=f.backup.listDestinations.useQuery,ex=f.backup.trigger.useMutation,tx=f.backup.list.useQuery,rx=f.backup.listLocations.useQuery,nx=f.backup.getEntries.useQuery,ox=f.backup.restore.useMutation,sx=f.backup.delete.useMutation,ax=f.backup.listArchives.useQuery,ix=f.backup.upsertDestinationPolicy.useMutation,lx=f.backup.previewSchedule.useQuery,cx=f.battery.getStatus.useQuery,ux=f.brightness.setBrightness.useMutation,dx=f.brightness.getStatus.useQuery,px=f.cameraCredentials.getCredentials.useQuery,fx=f.cameraCredentials.getStatus.useQuery,mx=f.cameraStreams.getCameraStreams.useQuery,hx=f.cameraStreams.getBrokerStreams.useQuery,kh=f.cameraStreams.getRtspEntries.useQuery,gx=f.decoder.supportsCodec.useQuery,bx=f.decoder.getInfo.useQuery,vx=f.decoder.createSession.useQuery,yx=f.decoder.destroySession.useQuery,xx=f.decoder.pushPacket.useQuery,wx=f.decoder.openStream.useQuery,kx=f.decoder.pullFrames.useQuery,Nx=f.decoder.pullHandles.useQuery,Sx=f.decoder.getFrame.useQuery,Cx=f.decoder.getShmStats.useQuery,Mx=f.decoder.updateConfig.useQuery,Ex=f.decoder.getStats.useQuery,Ax=f.decoder.listActiveSessions.useQuery,Px=f.decoder.reprobeHwaccel.useMutation,Rx=f.detectionPipeline.getDeviceSettingsContribution.useQuery,_x=f.detectionPipeline.getDeviceLiveContribution.useQuery,Ix=f.detectionPipeline.applyDeviceSettingsPatch.useMutation,Tx=f.deviceDiscovery.listDiscovered.useQuery,Dx=f.deviceDiscovery.refreshDiscovery.useMutation,Lx=f.deviceDiscovery.adoptDevice.useMutation,Ox=f.deviceDiscovery.releaseDevice.useMutation,$x=f.deviceDiscovery.getStatus.useQuery,Nh=f.deviceExport.getStatus.useQuery,Bx=f.deviceExport.listSupportedDeviceKinds.useQuery,Sh=f.deviceExport.listExposedDevices.useQuery,zx=f.deviceExport.exposeDevice.useMutation,Ch=f.deviceExport.unexposeDevice.useMutation,Fx=f.deviceExport.getDeviceSettingsContribution.useQuery,Gx=f.deviceExport.getDeviceLiveContribution.useQuery,Qx=f.deviceExport.applyDeviceSettingsPatch.useMutation,jx=f.deviceManager.allocateDeviceId.useMutation,Ux=f.deviceManager.registerDevice.useMutation,Hx=f.deviceManager.removeDevice.useMutation,Vx=f.deviceManager.persistConfig.useMutation,qx=f.deviceManager.loadConfig.useQuery,Wx=f.deviceManager.loadRuntimeState.useQuery,Kx=f.deviceManager.loadMeta.useQuery,Zx=f.deviceManager.setName.useMutation,Yx=f.deviceManager.setLocation.useMutation,Xx=f.deviceManager.setMetadata.useMutation,Jx=f.deviceManager.listLocations.useQuery,e1=f.deviceManager.addLocation.useMutation,t1=f.deviceManager.removeLocation.useMutation,r1=f.deviceManager.setDisabled.useMutation,n1=f.deviceManager.listPersistedByAddon.useQuery,Mh=f.deviceManager.listAll.useQuery,o1=f.deviceManager.getDevice.useQuery,s1=f.deviceManager.getChildren.useQuery,a1=f.deviceManager.getStreamSources.useQuery,i1=f.deviceManager.getConfigSchema.useQuery,l1=f.deviceManager.getSettingsSchema.useQuery,c1=f.deviceManager.updateConfig.useMutation,u1=f.deviceManager.enable.useMutation,d1=f.deviceManager.disable.useMutation,p1=f.deviceManager.remove.useMutation,f1=f.deviceManager.getStreamProfileMap.useQuery,m1=f.deviceManager.setStreamProfileMap.useMutation,h1=f.deviceManager.probeStreams.useMutation,g1=f.deviceManager.getBindings.useQuery,b1=f.deviceManager.getAllBindings.useQuery,v1=f.deviceManager.setWrapperActive.useMutation,y1=f.deviceManager.listWrappersForCap.useQuery,x1=f.deviceManager.listBindableCapsForDeviceType.useQuery,w1=f.deviceManager.getDeviceSettingsAggregate.useQuery,k1=f.deviceManager.getDeviceLiveInfoAggregate.useQuery,N1=f.deviceManager.getDeviceAggregate.useQuery,S1=f.deviceManager.updateDeviceField.useMutation,C1=f.deviceManager.updateDeviceFieldsBatch.useMutation,M1=f.deviceManager.discoverDevices.useMutation,E1=f.deviceManager.adoptDevice.useMutation,A1=f.deviceManager.getCreationSchema.useQuery,P1=f.deviceManager.createDevice.useMutation,R1=f.deviceManager.testCreationField.useMutation,_1=f.deviceManager.testField.useMutation,I1=f.deviceManager.getDeviceStatusAggregate.useQuery,T1=f.deviceOps.getStreamSources.useQuery,D1=f.deviceOps.getConfigEntries.useQuery,L1=f.deviceOps.setConfig.useMutation,O1=f.deviceOps.removeDevice.useMutation,$1=f.deviceOps.getSettingsSchema.useQuery,B1=f.deviceProvider.start.useMutation,z1=f.deviceProvider.stop.useMutation,F1=f.deviceProvider.getStatus.useQuery,G1=f.deviceProvider.getDevices.useQuery,Q1=f.deviceProvider.supportsDiscovery.useQuery,j1=f.deviceProvider.discoverDevices.useMutation,U1=f.deviceProvider.adoptDiscoveredDevice.useMutation,H1=f.deviceProvider.supportsManualCreation.useQuery,V1=f.deviceProvider.getChildCreationSchema.useQuery,q1=f.deviceProvider.createDevice.useMutation,W1=f.deviceProvider.testCreationField.useMutation,K1=f.deviceState.getSnapshot.useQuery,Z1=f.deviceState.getCapSlice.useQuery,Y1=f.deviceState.getAllSnapshots.useQuery,X1=f.deviceState.setCapSlice.useMutation,J1=f.deviceStatus.getStatus.useQuery,ew=f.doorbell.getStatus.useQuery,tw=f.events.getEvents.useQuery,rw=f.events.getEventThumbnail.useQuery,nw=f.events.getEventClipUrl.useQuery,ow=f.featureProbe.getStatus.useQuery,sw=f.integrations.list.useQuery,aw=f.integrations.get.useQuery,iw=f.integrations.getByAddonId.useQuery,lw=f.integrations.create.useMutation,cw=f.integrations.update.useMutation,uw=f.integrations.delete.useMutation,dw=f.integrations.getSettings.useQuery,pw=f.integrations.setSettings.useMutation,fw=f.integrations.getAvailableTypes.useQuery,mw=f.integrations.testConnection.useMutation,hw=f.intercom.startSession.useMutation,gw=f.intercom.handleAnswer.useMutation,bw=f.intercom.stopSession.useMutation,vw=f.intercom.startTalkSession.useMutation,yw=f.intercom.pushTalkPcm.useMutation,xw=f.intercom.endTalkSession.useMutation,ww=f.intercom.getStatus.useQuery,kw=f.localNetwork.list.useQuery,Nw=f.localNetwork.getPreferred.useQuery,Sw=f.localNetwork.getConnectionEndpoints.useQuery,Cw=f.localNetwork.getAllowedAddresses.useQuery,Mw=f.localNetwork.setAllowedAddresses.useMutation,Ew=f.localNetwork.resetAllowlistToBestMatch.useMutation,Aw=f.meshNetwork.getStatus.useQuery,Pw=f.meshNetwork.join.useMutation,Rw=f.meshNetwork.startLogin.useMutation,_w=f.meshNetwork.leave.useMutation,Iw=f.meshNetwork.logout.useMutation,Tw=f.meshNetwork.listPeers.useQuery,Dw=f.meshNetwork.testConnection.useMutation,Lw=f.metricsProvider.collectSnapshot.useQuery,Ow=f.metricsProvider.getCached.useQuery,$w=f.metricsProvider.getCurrent.useQuery,Bw=f.metricsProvider.getDiskSpace.useQuery,zw=f.metricsProvider.getGpuInfo.useQuery,Fw=f.metricsProvider.getCpuTemperature.useQuery,Gw=f.metricsProvider.getProcessStats.useQuery,Qw=f.metricsProvider.listAddonInstances.useQuery,jw=f.metricsProvider.getAddonStats.useQuery,Uw=f.metricsProvider.listNodeProcesses.useQuery,Hw=f.metricsProvider.killProcess.useMutation,Vw=f.motion.isDetected.useQuery,qw=f.motion.getStatus.useQuery,Ww=f.motionDetection.analyze.useMutation,Kw=f.motionDetection.removeCamera.useMutation,Zw=f.motionDetection.reset.useMutation,Yw=f.motionDetection.getDeviceSettingsContribution.useQuery,Xw=f.motionDetection.getDeviceLiveContribution.useQuery,Jw=f.motionDetection.applyDeviceSettingsPatch.useMutation,e2=f.motionTrigger.setMotionTrigger.useMutation,t2=f.motionTrigger.getStatus.useQuery,r2=f.motionZones.getOptions.useQuery,n2=f.motionZones.setZone.useMutation,o2=f.motionZones.getStatus.useQuery,s2=f.mqttBroker.listBrokers.useQuery,a2=f.mqttBroker.getBrokerConfig.useQuery,i2=f.mqttBroker.addBroker.useMutation,l2=f.mqttBroker.removeBroker.useMutation,c2=f.mqttBroker.testConnection.useMutation,u2=f.mqttBroker.startEmbeddedBroker.useMutation,d2=f.mqttBroker.stopEmbeddedBroker.useMutation,p2=f.mqttBroker.getStatus.useQuery,f2=f.nativeObjectDetection.getStatus.useQuery,m2=f.networkAccess.start.useMutation,h2=f.networkAccess.stop.useMutation,g2=f.networkAccess.getEndpoint.useQuery,b2=f.networkAccess.getStatus.useQuery,v2=f.networkAccess.listEndpoints.useQuery,y2=f.networkQuality.getDeviceStats.useQuery,x2=f.networkQuality.getAllStats.useQuery,w2=f.networkQuality.reportClientStats.useMutation,k2=f.nodes.topology.useQuery,N2=f.nodes.deployAddon.useMutation,S2=f.nodes.undeployAddon.useMutation,C2=f.nodes.restartAddon.useMutation,M2=f.nodes.restartProcess.useMutation,E2=f.nodes.restartNode.useMutation,A2=f.nodes.shutdownNode.useMutation,P2=f.nodes.renameNode.useMutation,R2=f.nodes.clusterAddonStatus.useQuery,_2=f.nodes.getCapUsageGraph.useQuery,I2=f.nodes.getNodeAddons.useQuery,T2=f.nodes.setProcessLogLevel.useMutation,D2=f.nodes.executeQuery.useMutation,L2=f.notificationOutput.send.useMutation,O2=f.notificationOutput.sendTest.useMutation,$2=f.osd.setOverlay.useMutation,B2=f.osd.getStatus.useQuery,z2=f.pipelineAnalytics.getActiveTracks.useQuery,F2=f.pipelineAnalytics.getTrack.useQuery,G2=f.pipelineAnalytics.listTracks.useQuery,Q2=f.pipelineAnalytics.clearTracks.useMutation,j2=f.pipelineAnalytics.getMotionEvents.useQuery,U2=f.pipelineAnalytics.getObjectEvents.useQuery,H2=f.pipelineAnalytics.getAudioEvents.useQuery,V2=f.pipelineAnalytics.getEventMedia.useQuery,q2=f.pipelineAnalytics.getTrackMedia.useQuery,W2=f.pipelineAnalytics.getDeviceSettingsContribution.useQuery,K2=f.pipelineAnalytics.getDeviceLiveContribution.useQuery,Z2=f.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Y2=f.pipelineExecutor.getAvailableEngines.useQuery,X2=f.pipelineExecutor.getSelectedEngine.useQuery,J2=f.pipelineExecutor.getDefaultSteps.useQuery,ek=f.pipelineExecutor.reprobeEngine.useMutation,tk=f.pipelineExecutor.getVideoPipelineSteps.useQuery,rk=f.pipelineExecutor.setVideoPipelineSteps.useMutation,nk=f.pipelineExecutor.getSchema.useQuery,ok=f.pipelineExecutor.getGlobalSteps.useQuery,sk=f.pipelineExecutor.getGlobalPipelineConfig.useQuery,ak=f.pipelineExecutor.getOrchestratorConfigSchema.useQuery,ik=f.pipelineExecutor.listTemplates.useQuery,lk=f.pipelineExecutor.saveTemplate.useMutation,ck=f.pipelineExecutor.updateTemplate.useMutation,uk=f.pipelineExecutor.deleteTemplate.useMutation,dk=f.pipelineExecutor.getCapabilities.useQuery,pk=f.pipelineExecutor.getAddonModels.useQuery,fk=f.pipelineExecutor.downloadModel.useMutation,mk=f.pipelineExecutor.deleteModel.useMutation,hk=f.pipelineExecutor.detect.useQuery,gk=f.pipelineExecutor.runPipeline.useMutation,bk=f.pipelineExecutor.runPipelineBatch.useMutation,vk=f.pipelineExecutor.cacheFrameInPool.useMutation,yk=f.pipelineExecutor.inferCached.useMutation,xk=f.pipelineExecutor.uncacheFrame.useMutation,wk=f.pipelineExecutor.getEffectiveTuning.useQuery,kk=f.pipelineExecutor.listLoadedEngines.useQuery,Nk=f.pipelineExecutor.spinEngine.useMutation,Sk=f.pipelineExecutor.killEngine.useMutation,Ck=f.pipelineExecutor.listReferenceImages.useQuery,Mk=f.pipelineExecutor.getReferenceImage.useQuery,Ek=f.pipelineExecutor.getReferenceAudioFiles.useQuery,Ak=f.pipelineExecutor.getReferenceAudio.useQuery,Pk=f.pipelineExecutor.getAudioCapabilities.useQuery,Rk=f.pipelineExecutor.runAudioTest.useMutation,_k=f.pipelineExecutor.getDetectionConfigSchema.useQuery,Ik=f.pipelineOrchestrator.assignPipeline.useMutation,Tk=f.pipelineOrchestrator.unassignPipeline.useMutation,Dk=f.pipelineOrchestrator.rebalance.useMutation,Lk=f.pipelineOrchestrator.getPipelineAssignments.useQuery,Ok=f.pipelineOrchestrator.getPipelineAssignment.useQuery,$k=f.pipelineOrchestrator.getAgentLoad.useQuery,Bk=f.pipelineOrchestrator.getGlobalMetrics.useQuery,zk=f.pipelineOrchestrator.getCameraMetrics.useQuery,Fk=f.pipelineOrchestrator.getCapabilityBindings.useQuery,Gk=f.pipelineOrchestrator.setCapabilityBinding.useMutation,Qk=f.pipelineOrchestrator.assignDecoder.useMutation,jk=f.pipelineOrchestrator.unassignDecoder.useMutation,Uk=f.pipelineOrchestrator.getDecoderAssignments.useQuery,Hk=f.pipelineOrchestrator.assignAudio.useMutation,Vk=f.pipelineOrchestrator.unassignAudio.useMutation,qk=f.pipelineOrchestrator.getAudioAssignment.useQuery,Wk=f.pipelineOrchestrator.getAudioNodeLoad.useQuery,Kk=f.pipelineOrchestrator.getAudioAssignments.useQuery,Zk=f.pipelineOrchestrator.getDecoderAssignment.useQuery,Yk=f.pipelineOrchestrator.getAgentSettings.useQuery,Xk=f.pipelineOrchestrator.listAgentSettings.useQuery,Jk=f.pipelineOrchestrator.setAgentAddonDefaults.useMutation,eN=f.pipelineOrchestrator.removeAgentSettings.useMutation,tN=f.pipelineOrchestrator.getCameraSettings.useQuery,rN=f.pipelineOrchestrator.setCameraStepToggle.useMutation,nN=f.pipelineOrchestrator.getCameraStepOverrides.useQuery,oN=f.pipelineOrchestrator.setCameraStepOverride.useMutation,sN=f.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,aN=f.pipelineOrchestrator.resolvePipeline.useQuery,iN=f.pipelineOrchestrator.listTemplates.useQuery,lN=f.pipelineOrchestrator.saveTemplate.useMutation,cN=f.pipelineOrchestrator.updateTemplate.useMutation,uN=f.pipelineOrchestrator.deleteTemplate.useMutation,dN=f.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,pN=f.pipelineOrchestrator.getDeviceLiveContribution.useQuery,fN=f.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,mN=f.pipelineRunner.attachCamera.useMutation,hN=f.pipelineRunner.detachCamera.useMutation,gN=f.pipelineRunner.reportMotion.useMutation,bN=f.pipelineRunner.getLocalLoad.useQuery,vN=f.pipelineRunner.getLocalMetrics.useQuery,yN=f.pipelineRunner.getCameraMetrics.useQuery,xN=f.pipelineRunner.getAllCameraMetrics.useQuery,wN=f.pipelineRunner.getLocalCameras.useQuery,kN=f.platformProbe.getCapabilities.useQuery,NN=f.platformProbe.getHardware.useQuery,SN=f.platformProbe.resolveInferenceConfig.useQuery,CN=f.platformProbe.resolveHwAccel.useQuery,MN=f.platformProbe.getHardwareEncoders.useQuery,EN=f.platformProbe.refreshHardwareEncoders.useMutation,AN=f.ptz.move.useMutation,PN=f.ptz.continuousMove.useMutation,RN=f.ptz.stop.useMutation,_N=f.ptz.getPresets.useQuery,IN=f.ptz.goToPreset.useMutation,TN=f.ptz.savePreset.useMutation,DN=f.ptz.deletePreset.useMutation,LN=f.ptz.getOptions.useQuery,ON=f.ptz.goHome.useMutation,$N=f.ptz.getPosition.useQuery,BN=f.ptz.setAutofocus.useMutation,zN=f.ptz.getStatus.useQuery,Eh=f.ptzAutotrack.getStatus.useQuery,Ah=f.ptzAutotrack.setEnabled.useMutation,FN=f.ptzAutotrack.getSettings.useQuery,Ph=f.ptzAutotrack.setSettings.useMutation,GN=f.reboot.reboot.useMutation,QN=f.recording.getSegments.useQuery,jN=f.recording.getPlaybackUrl.useQuery,UN=f.recording.getThumbnailAt.useQuery,HN=f.recordingEngine.getStatus.useQuery,VN=f.recordingEngine.enable.useMutation,qN=f.recordingEngine.disable.useMutation,WN=f.recordingEngine.getConfig.useQuery,KN=f.recordingEngine.updateConfig.useMutation,ZN=f.recordingEngine.getPlaylist.useQuery,YN=f.recordingEngine.getThumbnail.useQuery,XN=f.recordingEngine.getSegments.useQuery,JN=f.recordingEngine.getAvailability.useQuery,eS=f.recordingEngine.estimateStorage.useQuery,tS=f.recordingEngine.estimateGlobalStorage.useQuery,rS=f.recordingEngine.getStorageUsage.useQuery,nS=f.recordingEngine.setPolicy.useMutation,oS=f.recordingEngine.getPolicy.useQuery,sS=f.recordingEngine.getPolicyStatus.useQuery,aS=f.recordingEngine.getRetentionConfig.useQuery,iS=f.recordingEngine.updateRetentionConfig.useMutation,lS=f.recordingEngine.getMotionStats.useQuery,cS=f.settingsStore.get.useQuery,uS=f.settingsStore.set.useMutation,dS=f.settingsStore.query.useQuery,pS=f.settingsStore.insert.useMutation,fS=f.settingsStore.update.useMutation,mS=f.settingsStore.delete.useMutation,hS=f.settingsStore.count.useQuery,gS=f.settingsStore.isEmpty.useQuery,bS=f.settingsStore.declareCollection.useMutation,vS=f.snapshot.getSnapshot.useQuery,yS=f.snapshot.invalidateCache.useMutation,xS=f.snapshot.getStatus.useQuery,wS=f.snapshot.getDeviceSettingsContribution.useQuery,kS=f.snapshot.getDeviceLiveContribution.useQuery,NS=f.snapshot.applyDeviceSettingsPatch.useMutation,SS=f.snapshotProvider.supportsDevice.useQuery,CS=f.snapshotProvider.getSnapshot.useQuery,MS=f.storage.resolve.useQuery,ES=f.storage.write.useMutation,AS=f.storage.read.useQuery,PS=f.storage.exists.useQuery,RS=f.storage.list.useQuery,_S=f.storage.delete.useMutation,IS=f.storage.getAvailableSpace.useQuery,TS=f.storage.beginUpload.useMutation,DS=f.storage.writeChunk.useMutation,LS=f.storage.finalizeUpload.useMutation,OS=f.storage.abortUpload.useMutation,$S=f.storage.beginDownload.useMutation,BS=f.storage.readChunk.useQuery,zS=f.storage.endDownload.useMutation,FS=f.storage.listLocations.useQuery,GS=f.storage.getDefaultLocation.useQuery,QS=f.storage.upsertLocation.useMutation,jS=f.storage.deleteLocation.useMutation,US=f.storage.testLocation.useQuery,HS=f.storage.listProviders.useQuery,VS=f.storage.testConfig.useQuery,qS=f.streamBroker.publishCameraStream.useMutation,WS=f.streamBroker.retractCameraStream.useMutation,KS=f.streamBroker.assignProfile.useMutation,ZS=f.streamBroker.unassignProfile.useMutation,YS=f.streamBroker.listAllCameraStreams.useQuery,XS=f.streamBroker.listAllProfileSlots.useQuery,JS=f.streamBroker.getBrokerStats.useQuery,eC=f.streamBroker.listClients.useQuery,tC=f.streamBroker.killClient.useMutation,rC=f.streamBroker.restartProfile.useMutation,nC=f.streamBroker.getStreamUrl.useQuery,oC=f.streamBroker.getStreamWithCodec.useMutation,sC=f.streamBroker.releaseStreamWithCodec.useMutation,aC=f.streamBroker.subscribeAudioChunks.useMutation,iC=f.streamBroker.pullAudioChunks.useQuery,lC=f.streamBroker.unsubscribeAudioChunks.useMutation,cC=f.streamBroker.subscribeFrames.useMutation,uC=f.streamBroker.pullFrameHandles.useQuery,dC=f.streamBroker.unsubscribeFrames.useMutation,pC=f.streamBroker.setPreBufferDuration.useMutation,fC=f.streamBroker.getPreBufferInfo.useQuery,mC=f.streamBroker.getRtspPort.useQuery,hC=f.streamBroker.getAllRtspEntries.useQuery,gC=f.streamBroker.getRtspEntry.useQuery,bC=f.streamBroker.regenerateRtspToken.useMutation,vC=f.streamBroker.setRtspEnabled.useMutation,yC=f.streamBroker.isRtspEnabled.useQuery,xC=f.streamBroker.getDeviceSettingsContribution.useQuery,wC=f.streamBroker.getDeviceLiveContribution.useQuery,kC=f.streamBroker.applyDeviceSettingsPatch.useMutation,NC=f.streamParams.getOptions.useQuery,SC=f.streamParams.setProfile.useMutation,CC=f.streamParams.getConfigSchema.useQuery,MC=f.streamParams.getStatus.useQuery,EC=f.switch.setState.useMutation,AC=f.switch.getStatus.useQuery,PC=f.system.info.useQuery,RC=f.system.health.useQuery,_C=f.system.featureFlags.useQuery,IC=f.system.networkAddresses.useQuery,TC=f.system.getRetentionConfig.useQuery,DC=f.system.setRetentionConfig.useMutation,LC=f.system.forceRetentionCleanup.useMutation,OC=f.toast.onToast.useSubscription,$C=f.turnProvider.getTurnServers.useQuery,BC=f.userManagement.listUsers.useQuery,zC=f.userManagement.createUser.useMutation,FC=f.userManagement.updateUser.useMutation,GC=f.userManagement.deleteUser.useMutation,QC=f.userManagement.resetPassword.useMutation,jC=f.userManagement.setUserScopes.useMutation,UC=f.userManagement.validateCredentials.useMutation,HC=f.userManagement.listApiKeys.useQuery,VC=f.userManagement.createApiKey.useMutation,qC=f.userManagement.revokeApiKey.useMutation,WC=f.userManagement.validateApiKey.useMutation,KC=f.userManagement.createScopedToken.useMutation,ZC=f.userManagement.revokeScopedToken.useMutation,YC=f.userManagement.validateScopedToken.useQuery,XC=f.userManagement.listScopedTokens.useQuery,JC=f.userManagement.setupTotp.useMutation,e5=f.userManagement.confirmTotp.useMutation,t5=f.userManagement.disableTotp.useMutation,r5=f.userManagement.getTotpStatus.useQuery,n5=f.userManagement.verifyTotp.useMutation,o5=f.userManagement.oauthIssueCode.useMutation,s5=f.userManagement.oauthExchangeCode.useMutation,a5=f.userManagement.oauthRefresh.useMutation,i5=f.userManagement.oauthVerifyAccessToken.useQuery,l5=f.userManagement.listOauthSessions.useQuery,c5=f.userManagement.revokeOauthSession.useMutation,u5=f.webrtcSession.listStreams.useQuery,d5=f.webrtcSession.createSession.useMutation,p5=f.webrtcSession.handleOffer.useMutation,f5=f.webrtcSession.handleAnswer.useMutation,m5=f.webrtcSession.closeSession.useMutation,h5=f.webrtcSession.hasAdaptiveBitrate.useQuery,g5=f.zoneAnalytics.getCurrentSnapshot.useQuery,b5=f.zoneAnalytics.getZoneHistory.useQuery,v5=f.zoneAnalytics.getCameraHistory.useQuery,y5=f.zoneAnalytics.getUnzonedHistory.useQuery,x5=f.zoneRules.listRules.useQuery,w5=f.zoneRules.setRules.useMutation,k5=f.zones.listZones.useQuery,N5=f.zones.addZone.useMutation,S5=f.zones.removeZone.useMutation,C5=f.zones.updateZone.useMutation,fl=ct("camstack:widget-registry",null),Tr=new Map,hr=new Map,fs=new Set;function co(e,t){return`${e}::${t}`}function Rh(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function _h(e){if(!e||typeof e!="object")return typeof e;const t=e,r=Object.getPrototypeOf(t),n=r&&typeof r=="object"?r.constructor?.name:void 0;return{ownKeys:Object.keys(t),allKeys:Object.getOwnPropertyNames(t),proto:typeof n=="string"?n:void 0}}async function ml(e,t,r){const n=co(e,t),s=Tr.get(n);if(s)return s;const a=hr.get(n);if(a)return a;fs.has(e)||($d(),Id([{name:e,entry:r,type:"module"}],{force:!1}),fs.add(e));const i=_d(`${e}/${t.startsWith("./")?t.slice(2):t}`).then(c=>{if(!Rh(c)){const u=_h(c);throw new Error(`Remote ${e} (${r}) does not expose a default record on '${t}'. Got: ${JSON.stringify(u)}`)}const l=c.default;return Tr.set(n,l),hr.delete(n),l}).catch(c=>{throw hr.delete(n),c});return hr.set(n,i),i}function On(e,t){return Tr.get(co(e,t))}var Ih=3e4,Th=2e3;function M5({children:e}){const t=or(),r=W(Date.now()),{data:n}=wh(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const u=l.state.data;return u&&u.length>0||Date.now()-r.current>=Ih?!1:Th}});Fr("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=E(0),i=q(()=>n??[],[n]);Q(()=>{if(i.length===0)return;let l=!1;const u=new Set;for(const d of i){const p=co(d.remote.remoteName,d.remote.exposedModule);if(u.has(p)||(u.add(p),Tr.has(p)))continue;const h=d.bundleUrl;ml(d.remote.remoteName,d.remote.exposedModule,h).then(()=>{l||a(g=>g+1)}).catch(g=>{const b=g instanceof Error?g.message:String(g);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load widget remote",{remoteName:d.remote.remoteName,exposedModule:d.remote.exposedModule,entryUrl:h,reason:b})})}return()=>{l=!0}},[i]);const c=q(()=>{const l=new Map,u=new Map;for(const p of i)l.set(`${p.addonId}/${p.stableId}`,p),u.set(p.remote.remoteName,p.bundleUrl);const d=(p,h)=>({widgetId:p,addonId:h.addonId,stableId:h.stableId,tab:h.tab,subTab:h.subTab,label:h.label,order:h.order,kind:h.kind,remote:h.remote,description:h.description,icon:h.icon,bundleUrl:h.bundleUrl,hosts:h.hosts,requires:h.requires,defaultSize:h.defaultSize,allowedSizes:h.allowedSizes,defaultColumns:h.defaultColumns,defaultRows:h.defaultRows});return{resolve:p=>{const h=l.get(p);if(!h)return;const g=On(h.remote.remoteName,h.remote.exposedModule);if(!g)return null;const b=g[h.remote.componentKey??h.stableId];if(b)return b},metadata:p=>{const h=l.get(p);if(h)return d(p,h)},listAll:()=>{const p=[];for(const[h,g]of l)p.push(d(h,g));return p},entryUrlFor:p=>u.get(p)}},[i,s]);return o(fl.Provider,{value:c,children:e})}function E5(e){return uo().resolve(e)}function Dh(e){return uo().metadata(e)}function A5(){return uo().listAll()}function Lh(e,t){const r=hl(),n=t??r?.entryUrlFor(e.remoteName),[s,a]=E(0),[i,c]=E(!1);return Q(()=>{if(!n||(c(!1),On(e.remoteName,e.exposedModule)))return;let l=!1;return ml(e.remoteName,e.exposedModule,n).then(()=>{l||a(u=>u+1)}).catch(u=>{const d=u instanceof Error?u.message:String(u);(typeof globalThis<"u"?globalThis.console:void 0)?.error?.("[WidgetRegistry] Failed to load remote component",{remoteName:e.remoteName,exposedModule:e.exposedModule,entryUrl:n,reason:d}),l||c(!0)}),()=>{l=!0}},[e.remoteName,e.exposedModule,n]),q(()=>{if(!n||i)return;const l=On(e.remoteName,e.exposedModule);if(!l)return null;const u=e.componentKey;return u===void 0?Object.values(l)[0]??void 0:l[u]??void 0},[e.remoteName,e.exposedModule,e.componentKey,n,s,i])}function uo(){const e=hl();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function hl(){return Oh(fl)}function Oh(e){return Re(e)}var ms={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 $h(e,t,r){const n=r?.defaultSpeed??.5,s=r?.pulseMs??250,a=r?.enabled??!0,i=Gt(e,a?t:null)?.ptz,[c,l]=E([]),[u,d]=E(null),[p,h]=E(!1),[g,b]=E(null),v=w=>{const N=w instanceof Error?w.message:String(w);return N.includes("provider not available")||N.includes("no 'ptz' binding")},y=R(async()=>{if(!(!a||!i))try{l(await i.getPresets({}))}catch(w){if(v(w))return;b(w instanceof Error?w.message:String(w))}},[i,a]),x=R(async()=>{if(!(!a||!i))try{d(await i.getOptions({}))}catch(w){if(v(w))return;b(w instanceof Error?w.message:String(w))}},[i,a]);Q(()=>{y(),x()},[y,x]);const k=R(async w=>{if(!(!a||!i)){b(null),h(!0);try{return await w()}catch(N){b(N instanceof Error?N.message:String(N));return}finally{h(!1)}}},[a,i]);return{move:R(async(w,N)=>{if(!i)return;const S=ms[w],M=N??n;await k(async()=>{await i.move({pan:S.pan,tilt:S.tilt,speed:M}),await new Promise(P=>setTimeout(P,s)),await i.stop({})})},[i,n,s,k]),startContinuous:R(async(w,N)=>{if(!i)return;const S=ms[w],M=N??n;await k(()=>i.continuousMove({pan:S.pan,tilt:S.tilt,speed:M}))},[i,n,k]),stopContinuous:R(async()=>{i&&await k(()=>i.stop({}))},[i,k]),zoom:R(async(w,N)=>{if(!i)return;const S=w==="in"?1:-1,M=N??n;await k(async()=>{await i.move({zoom:S,speed:M}),await new Promise(P=>setTimeout(P,s)),await i.stop({})})},[i,n,s,k]),goHome:R(async()=>{i&&await k(()=>i.goHome({}))},[i,k]),goToPreset:R(async w=>{i&&await k(()=>i.goToPreset({presetId:w}))},[i,k]),savePreset:R(async w=>{if(i)return k(async()=>{const N=new Set(c.map(P=>Number(P.id)).filter(P=>Number.isInteger(P)&&P>=0));let S=0;for(;N.has(S);)S+=1;const M=String(S);return await i.savePreset({presetId:M,name:w}),await y(),M})},[i,c,y,k]),deletePreset:R(async w=>{i&&await k(async()=>{await i.deletePreset({presetId:w}),await y()})},[i,y,k]),presets:c,refreshPresets:y,options:u,busy:p,error:g}}function gr({direction:e,icon:t,disabled:r,className:n,variant:s,onMove:a,onStart:i,onStop:c}){const[l,u]=E(null),[d,p]=E(!1),h=R(x=>{if(r)return;x.currentTarget.setPointerCapture(x.pointerId),u(Date.now()),p(!1);const k=setTimeout(()=>{p(!0),i(e)},250);x.currentTarget.dataset.timer=String(k)},[e,r,i]),g=R(x=>{const k=Number(x.currentTarget.dataset.timer);k&&clearTimeout(k),x.currentTarget.dataset.timer="",d?c():l!==null&&a(e),u(null),p(!1)},[d,e,a,c,l]),b=R(x=>{const k=Number(x.currentTarget.dataset.timer);k&&clearTimeout(k),x.currentTarget.dataset.timer="",d&&c(),u(null),p(!1)},[d,c]),v=s==="panel"?"h-9 w-9":"h-7 w-7",y=s==="panel"?"h-4 w-4":"h-3.5 w-3.5";return o("button",{type:"button",disabled:r,onPointerDown:h,onPointerUp:g,onPointerCancel:b,className:C("flex items-center justify-center rounded transition-colors disabled:opacity-40",s==="panel"?"text-foreground hover:bg-surface-hover active:bg-surface-hover/80":"text-white hover:bg-white/15 active:bg-white/25",v,n),title:e,children:o(t,{className:y})})}function Bh({controls:e,mode:t="overlay",showPresets:r,showZoom:n=!0,showHome:s=!0,className:a}){const{move:i,startContinuous:c,stopContinuous:l,zoom:u,goHome:d,goToPreset:p,savePreset:h,deletePreset:g,presets:b,options:v,busy:y,error:x}=e,k=Gr(),[w,N]=E(!1),[S,M]=E(""),P=(r??b.length>0)&&b.length>0,A=t==="panel",V=A&&(v?.supportsPresets??!1),H=v?.maxPresets!==void 0&&b.length>=v.maxPresets,ae=R(async()=>{const Z=S.trim();!Z||y||H||await h(Z)!==void 0&&M("")},[S,y,H,h]),pe=R(async(Z,D)=>{await k({title:"Delete preset",message:`Delete PTZ preset "${D}"? This removes it from the camera.`,confirmLabel:"Delete",variant:"danger"})&&await g(Z)},[k,g]),ne=A?"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",se=C(A?"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",y&&"ring-1 ring-primary/40"),oe=A?"h-9 w-9":"h-7 w-7",J=A?"h-4 w-4":"h-3.5 w-3.5",K=A?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",fe=A?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return m("div",{className:C(ne,a),children:[x&&m("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: ",x]}),m("div",{className:C(se,A&&"justify-center"),children:[m("div",{className:"grid grid-cols-3 gap-0.5",children:[o("span",{"aria-hidden":!0,className:A?"h-9 w-9":"h-7 w-7"}),o(gr,{direction:"up",icon:Vd,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:A?"h-9 w-9":"h-7 w-7"}),o(gr,{direction:"left",icon:Ud,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:A?"h-9 w-9":"h-7 w-7"}),o(gr,{direction:"right",icon:Hd,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:A?"h-9 w-9":"h-7 w-7"}),o(gr,{direction:"down",icon:jd,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:A?"h-9 w-9":"h-7 w-7"})]}),(n||s)&&o("div",{className:fe}),m("div",{className:"flex flex-col gap-0.5",children:[n&&m(we,{children:[o("button",{type:"button",onClick:()=>u("in"),disabled:y,title:"Zoom in",className:C("flex items-center justify-center rounded disabled:opacity-40",oe,K),children:o($p,{className:J})}),o("button",{type:"button",onClick:()=>u("out"),disabled:y,title:"Zoom out",className:C("flex items-center justify-center rounded disabled:opacity-40",oe,K),children:o(Bp,{className:J})})]}),s&&o("button",{type:"button",onClick:()=>d(),disabled:y,title:"Go home",className:C("flex items-center justify-center rounded disabled:opacity-40",oe,K),children:o(ni,{className:J})})]}),P&&m("div",{className:"relative",children:[m("button",{type:"button",onClick:()=>N(Z=>!Z),disabled:y,className:C("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",A?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",o(xt,{className:C("h-3 w-3 transition-transform",w&&"rotate-180")})]}),w&&o("div",{className:C("absolute right-0 top-full mt-1 min-w-[140px] rounded-lg shadow-xl py-1 z-20",A?"bg-surface border border-border":"border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:b.map(Z=>m("div",{className:C("group flex items-center",A?"hover:bg-surface-hover":"hover:bg-white/15"),children:[o("button",{type:"button",onClick:()=>{p(Z.id),N(!1)},disabled:y,className:C("flex-1 px-3 py-1.5 text-left text-[10px] disabled:opacity-40",A?"text-foreground":"text-white"),children:Z.name||Z.id}),V&&o("button",{type:"button",onClick:()=>void pe(Z.id,Z.name||Z.id),disabled:y,title:`Delete preset ${Z.name||Z.id}`,className:C("mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded","text-foreground-subtle hover:bg-danger/15 hover:text-danger disabled:opacity-40"),children:o(_e,{className:"h-3 w-3"})})]},Z.id))})]})]}),V&&m("div",{className:"flex flex-col gap-1 rounded-lg border border-border p-2",children:[m("div",{className:"flex items-center gap-2",children:[o("input",{type:"text",value:S,onChange:Z=>M(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&ae()},disabled:y||H,placeholder:"New preset name",maxLength:64,className:C("min-w-0 flex-1 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground","placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary/50","disabled:opacity-40")}),m("button",{type:"button",onClick:()=>void ae(),disabled:y||H||S.trim().length===0,title:H?`Camera preset limit reached (${v?.maxPresets})`:"Save current position as a new preset",className:C("flex h-7 shrink-0 items-center gap-1 rounded px-2 text-[10px] font-medium","bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-40"),children:[o(zt,{className:"h-3 w-3"}),"Save current position"]})]}),H&&m("span",{className:"text-[10px] text-foreground-subtle",children:["Camera preset limit reached (",v?.maxPresets,"). Delete a preset to add a new one."]})]})]})}function zh({deviceId:e}){const t=Gt(tt().trpcClient,e),[r,n]=E(null),[s,a]=E(!1);Q(()=>{if(!t)return;let c=!1;return(async()=>{try{const l=await t.ptz?.getStatus({});if(c||!l)return;n(l.autofocus)}catch{}})(),()=>{c=!0}},[t]);const i=R(async()=>{if(!(!t?.ptz||r===null)){a(!0);try{const c=!r;await t.ptz.setAutofocus({enabled:c}),n(c)}catch(c){console.error("ptz.setAutofocus failed",c)}finally{a(!1)}}},[t,r]);return r===null?null:m("div",{className:"flex items-center justify-between border-t border-border/40 mt-2 pt-2",children:[o("span",{className:"text-[10.5px] font-semibold text-foreground",children:"Autofocus"}),m("button",{type:"button",onClick:()=>void i(),disabled:s,"aria-pressed":r,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${r?"bg-success/15 text-success hover:bg-success/25":"bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground"} disabled:opacity-50`,children:[o("span",{className:`h-1.5 w-1.5 rounded-full ${r?"bg-success":"bg-foreground-subtle/40"}`}),r?"On":"Off"]})]})}function Fh({deviceId:e}){const t=tt(),r=Number.isFinite(e),n=$h(t.trpcClient,r?e:0,{enabled:r});if(!r)return m("div",{className:"flex items-center justify-center h-full text-[11px] text-foreground-subtle italic",children:["Device #",e," not loaded."]});const s=n.options?.hasAutofocus===!0;return m("div",{className:"flex flex-col h-full overflow-y-auto",children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider mb-2",children:"PTZ"}),o(Bh,{controls:n,mode:"panel"}),s&&o(zh,{deviceId:e})]})}function Gh(e){const t=or(),r=Eh({deviceId:e??0},{enabled:e!==null&&Number.isFinite(e),refetchInterval:5e3,retry:1}),n=Ah({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),s=Ph({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=R(async l=>{e!==null&&await n.mutateAsync({deviceId:e,enabled:l})},[e,n]),i=R(async l=>{e!==null&&await s.mutateAsync({deviceId:e,settings:l})},[e,s]),c=r.error?r.error.message:n.error?n.error.message:s.error?s.error.message:null;return{status:r.data??null,isLoading:r.isLoading,isPending:n.isPending||s.isPending,error:c,setEnabled:a,setSettings:i}}function Qh({deviceId:e}){const{status:t,isLoading:r,isPending:n,error:s,setEnabled:a,setSettings:i}=Gh(Number.isFinite(e)?e:null),[c,l]=E({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[u,d]=E(!1);return Q(()=>{if(u)return;const p=t?.currentSettings;p&&l({targetType:p.targetType,stopDelaySeconds:p.stopDelaySeconds,disappearDelaySeconds:p.disappearDelaySeconds})},[t,u]),r&&!t?m("div",{className:"flex items-center gap-2 px-3 py-2 text-[10.5px] text-foreground-subtle",children:[o(Fe,{className:"h-3 w-3 animate-spin"}),"Loading autotrack…"]}):m("div",{className:"border-t border-border/40 mt-2 pt-2 px-1 space-y-2",children:[m("div",{className:"flex items-center justify-between px-2",children:[m("h3",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:[o(Jn,{className:"h-3 w-3 text-primary"}),"Autotrack"]}),m("button",{type:"button",onClick:()=>{a(!(t?.enabled??!1))},disabled:n,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${t?.enabled?"bg-success/15 text-success hover:bg-success/25":"bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground"} disabled:opacity-50`,"aria-pressed":t?.enabled??!1,children:[o("span",{className:`h-1.5 w-1.5 rounded-full ${t?.enabled?"bg-success":"bg-foreground-subtle/40"}`}),t?.enabled?"Enabled":"Disabled"]})]}),s&&m("div",{className:"flex items-start gap-1.5 rounded-md border border-danger/30 bg-danger/5 px-2 py-1.5 text-[10px] text-danger",children:[o($t,{className:"h-3 w-3 flex-shrink-0 mt-0.5"}),o("span",{className:"leading-snug break-words",children:s})]}),m("div",{className:"grid grid-cols-2 gap-2 px-2",children:[(t?.supportedTargetTypes?.length??0)>0&&m("label",{className:"col-span-2 flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Target type"}),o("select",{value:c.targetType,onFocus:()=>d(!0),onChange:p=>l(h=>({...h,targetType:p.target.value})),onBlur:()=>{d(!1);const p=t?.currentSettings?.targetType??"";c.targetType!==p&&i({targetType:c.targetType})},disabled:n,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50",children:(t?.supportedTargetTypes??[]).map(p=>o("option",{value:p.value,children:p.label},p.value))})]}),m("label",{className:"flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Stop delay (s)"}),o("input",{type:"number",min:0,max:300,value:c.stopDelaySeconds,onFocus:()=>d(!0),onChange:p=>l(h=>({...h,stopDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{d(!1);const p=t?.currentSettings?.stopDelaySeconds??30;c.stopDelaySeconds!==p&&i({stopDelaySeconds:c.stopDelaySeconds})},disabled:n,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]}),m("label",{className:"flex flex-col gap-1",children:[o("span",{className:"text-[10px] font-medium text-foreground-subtle",children:"Disappear delay (s)"}),o("input",{type:"number",min:0,max:300,value:c.disappearDelaySeconds,onFocus:()=>d(!0),onChange:p=>l(h=>({...h,disappearDelaySeconds:Number(p.target.value)||0})),onBlur:()=>{d(!1);const p=t?.currentSettings?.disappearDelaySeconds??15;c.disappearDelaySeconds!==p&&i({disappearDelaySeconds:c.disappearDelaySeconds})},disabled:n,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50"})]})]}),o("p",{className:"px-2 text-[9.5px] text-foreground-subtle leading-snug italic",children:"Settings save on blur. Vendor support varies — Reolink honours all three; Hikvision honours target type + stop delay only (disappear delay is accepted but ignored at firmware push)."})]})}var po=ct("camstack:player-overlays-state",null),fo=ct("camstack:player-overlays-actions",null);function P5({children:e}){const[t,r]=E(()=>new Map),[n,s]=E(()=>new Map),a=R(p=>{r(h=>{const g=new Map(h);return g.set(p.id,p),g})},[]),i=R(p=>{r(h=>{if(!h.has(p))return h;const g=new Map(h);return g.delete(p),g})},[]),c=R(p=>{s(h=>{const g=new Map(h);return g.set(p.id,p),g})},[]),l=R(p=>{s(h=>{if(!h.has(p))return h;const g=new Map(h);return g.delete(p),g})},[]),u=q(()=>({layers:t,buttons:n}),[t,n]),d=q(()=>({setLayer:a,removeLayer:i,setButton:c,removeButton:l}),[a,i,c,l]);return o(po.Provider,{value:u,children:o(fo.Provider,{value:d,children:e})})}function R5(){const e=Re(po);return q(()=>e?[...e.layers.values()].sort((t,r)=>t.order-r.order):[],[e])}function jh(){const e=Re(po);return q(()=>e?[...e.buttons.values()].sort((t,r)=>t.order-r.order):[],[e])}function Uh(e){const t=Re(fo);Q(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function _5(e){const t=Re(fo);Q(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}function Hh({options:e,cells:t,onCellsChange:r}){const{gridWidth:n,gridHeight:s}=e,a=n*s,i=W(!1),c=W(!0),l=W(new Set),[,u]=E(0),d=R((b,v)=>{if(b<0||b>=a||t[b]===v)return;const y=[...t];for(;y.length<a;)y.push(!1);y.length=a,y[b]=v,r(y)},[t,a,r]),p=R(b=>v=>{v.preventDefault();const y=!t[b];i.current=!0,c.current=y,l.current=new Set([b]),d(b,y),u(x=>x+1)},[t,d]),h=R(b=>()=>{i.current&&(l.current.has(b)||(l.current.add(b),d(b,c.current)))},[d]),g=R(()=>{i.current&&(i.current=!1,l.current=new Set)},[]);return o("div",{className:"absolute inset-0 select-none grid",style:{gridTemplateColumns:`repeat(${String(n)}, 1fr)`,gridTemplateRows:`repeat(${String(s)}, 1fr)`},onPointerUp:g,onPointerLeave:g,children:Array.from({length:a},(b,v)=>{const y=t[v]===!0;return o("button",{type:"button","aria-label":`motion cell ${String(v)}`,"aria-pressed":y,onPointerDown:p(v),onPointerEnter:h(v),className:y?"border border-primary/70 bg-primary/55 hover:bg-primary/65 transition-colors":"border border-white/25 bg-white/10 hover:bg-white/20 transition-colors"},v)})})}function Vh(e){const t=e instanceof Error?e.message:String(e);return t.includes("provider not available")||t.includes("motion-zones")}function hs(e,t){const r=t.gridWidth*t.gridHeight,n=new Array(r);for(let s=0;s<r;s+=1)n[s]=e[s]===!0;return n}function qh(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r])return!1;return!0}function Wh({deviceId:e}){const t=Gt(tt().trpcClient,e),[r,n]=E(null),[s,a]=E(!1),[i,c]=E(null),[l,u]=E(null),[d,p]=E(!1),[h,g]=E(!1),b=W(!1);Q(()=>{if(!t)return;let M=!1;return(async()=>{try{const P=await t.motionZones?.getOptions({});if(M||!P||(n(P),b.current))return;const A=await t.motionZones?.getStatus({});if(M||!A)return;b.current=!0;const V=hs(A.cells,P);u(V),c(V)}catch(P){if(M)return;Vh(P)?a(!0):console.error("motion-zones load failed",P)}})(),()=>{M=!0}},[t]);const v=q(()=>i!==null&&l!==null&&!qh(i,l),[i,l]),y=q(()=>i?i.reduce((M,P)=>P?M+1:M,0):0,[i]),x=r?r.gridWidth*r.gridHeight:0,k=R(M=>{x>0&&c(new Array(x).fill(M))},[x]),w=R(()=>{c(M=>M&&M.map(P=>!P))},[]),N=R(()=>{l&&c([...l])},[l]),S=R(async()=>{if(!(!i||!t?.motionZones||!r)){p(!0);try{await t.motionZones.setZone({patch:{cells:[...i]}});const M=await t.motionZones.getStatus({});if(M){const P=hs(M.cells,r);u(P),c(P)}}catch(M){console.error("motion-zones.setZone failed",M)}finally{p(!1)}}},[i,t,r]);return Uh(q(()=>h&&!s&&r&&i?{id:"motion-zones",order:110,node:o(Hh,{options:r,cells:i,onCellsChange:c})}:null,[h,s,r,i])),m("div",{className:"flex flex-col gap-3",children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Motion Zones"}),s?o("p",{className:`${ur} leading-relaxed`,children:"This camera doesn't expose an on-board motion-detection grid."}):!s&&r!==null&&i!==null?m(we,{children:[m("p",{className:`${ur} leading-relaxed`,children:["Toggle"," ",o("strong",{className:"text-foreground",children:"Edit grid"})," to paint the region the camera watches for motion directly on the live frame, then ",o("strong",{className:"text-foreground",children:"Save"})," to push the mask to the camera. Detection on/off and sensitivity are set in the"," ",o("strong",{className:"text-foreground",children:"On-camera motion"})," section."]}),m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("button",{type:"button",onClick:()=>g(M=>!M),disabled:d,"aria-pressed":h,className:h?"rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors":"rounded-md border border-border bg-surface px-2.5 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:h?"Done editing":"Edit grid"}),o("button",{type:"button",onClick:()=>k(!0),disabled:d,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"All on"}),o("button",{type:"button",onClick:()=>k(!1),disabled:d,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"All off"}),o("button",{type:"button",onClick:w,disabled:d,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"Invert"}),m("span",{className:`${ur} ml-1 tabular-nums`,children:[y," / ",x," cells · ",r.gridWidth,"×",r.gridHeight]}),o("span",{className:"flex-1"}),o("button",{type:"button",onClick:N,disabled:d||!v,className:"rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",children:"Revert"}),o("button",{type:"button",onClick:()=>void S(),disabled:d||!v,className:"rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors",children:d?"Saving…":"Save"})]})]}):o("p",{className:`${ur} leading-relaxed`,children:"Loading the camera's motion grid…"})]})}var Kh={"host/motion-zones-grid":Wh,"host/ptz-panel":Fh,"host/ptz-autotrack":Qh};function Zh(e){const{widgetId:t,deviceId:r}=e,n=Kh[t];return n!==void 0?r===void 0?o(qt,{widgetId:t,reason:"missing-device-context"}):o(n,{deviceId:r}):o(Yh,{...e})}function Yh(e){const{widgetId:t}=e,r=Dh(t);return r===void 0?o(qt,{widgetId:t,reason:"unknown"}):o(Xh,{...e,metadata:r})}function Xh(e){const{widgetId:t,host:r="device-tab",config:n,deviceId:s,integrationId:a,instanceId:i,size:c,columns:l,rows:u,metadata:d}=e,p=Lh(d.remote,d.bundleUrl),h=q(()=>i??t,[i,t]);return p===null?o(Jh,{}):p===void 0?o(qt,{widgetId:t,reason:"missing-export"}):d.requires.deviceContext&&s===void 0?o(qt,{widgetId:t,reason:"missing-device-context"}):d.requires.integrationContext&&a===void 0?o(qt,{widgetId:t,reason:"missing-integration-context"}):o(p,{instanceId:h,host:r,config:n,deviceId:s,integrationId:a,size:c,columns:l,rows:u})}function Jh(){return m("div",{className:"rounded-lg border border-border bg-surface/40 p-4 animate-pulse",children:[o("div",{className:"h-3 w-24 bg-foreground-subtle/20 rounded mb-2"}),o("div",{className:"h-2 w-full bg-foreground-subtle/10 rounded mb-1"}),o("div",{className:"h-2 w-3/4 bg-foreground-subtle/10 rounded"})]})}function qt({widgetId:e,reason:t}){return o("div",{className:"rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",children:t==="unknown"?`Widget "${e}" not registered`:t==="missing-export"?`Widget "${e}" bundle does not export this stableId`:t==="missing-device-context"?`Widget "${e}" requires a deviceId`:`Widget "${e}" requires an integrationId`})}var kt="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",jr="block text-[11px] font-medium text-foreground mb-1",eg="text-[10px] text-foreground-subtle mt-0.5";function Ae({label:e,description:t,required:r,span:n,children:s,translationFn:a}){const i=n===2?"col-span-2":n===3?"col-span-3":n===4?"col-span-4":"col-span-1",c=qe(e,a),l=qe(t,a),u=c!==void 0&&c!=="";return m("div",{className:`${i} min-w-0`,children:[u&&m("label",{className:jr,children:[c,r&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),s,l&&o("p",{className:eg,children:l})]})}function tg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("input",{type:e.inputType??"text",className:kt,value:t==null?"":String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:n||e.disabled,onChange:a=>r(a.target.value)})})}function rg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const[a,i]=E(t==null?"":String(t)),c=W(!1);Q(()=>{c.current||i(t==null?"":String(t))},[t]);const l=u=>{if(i(u),u===""||u==="-"){r(void 0);return}const d=Number(u);Number.isNaN(d)||r(d)};return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("div",{className:"flex items-center gap-1",children:[o("input",{type:"number",className:kt,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:n||e.disabled,onFocus:()=>{c.current=!0},onBlur:()=>{c.current=!1},onChange:u=>l(u.target.value)}),e.unit&&o("span",{className:"text-xs text-foreground-subtle whitespace-nowrap",children:e.unit})]})})}function ng({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=!!t,i=n||e.disabled;return e.style==="checkbox"?o(Ae,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[o("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-border accent-primary",checked:a,disabled:i,onChange:c=>r(c.target.checked)}),o("span",{className:"text-xs font-medium text-foreground",children:qe(e.label,s)}),e.required&&o("span",{className:"text-danger",children:"*"})]})}):o(Ae,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("div",{className:"flex items-center justify-between",children:[m("span",{className:jr+" mb-0",children:[qe(e.label,s),e.required&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),o("button",{type:"button",role:"switch","aria-checked":a,disabled:i,onClick:()=>!i&&r(!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:o("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 og({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=e.options.some(i=>i.value==="");return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("select",{className:kt,value:t==null?"":String(t),disabled:n||e.disabled,onChange:i=>r(i.target.value),children:[!e.required&&!a&&o("option",{value:"",children:"— Select —"}),e.options.map(i=>o("option",{value:i.value,children:i.label},i.value))]})})}function sg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=Array.isArray(t)?t:[],i=c=>{if(a.includes(c))r(a.filter(l=>l!==c));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;r([...a,c])}};return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("div",{className:"flex flex-wrap gap-2",children:e.options.map(c=>{const l=a.includes(c.value);return m("label",{className:["flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors",l?"border-primary bg-primary/10 text-primary":"border-border bg-background text-foreground hover:bg-surface",n||e.disabled?"opacity-50 cursor-not-allowed":""].join(" "),children:[o("input",{type:"checkbox",className:"sr-only",checked:l,disabled:n||e.disabled,onChange:()=>i(c.value)}),c.label]},c.value)})})})}function ag({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const[a,i]=E(!1),c=e.showToggle!==!1;return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("div",{className:"relative",children:[o("input",{type:a?"text":"password",className:kt+(c?" pr-9":""),value:t==null?"":String(t),placeholder:e.placeholder,disabled:n||e.disabled,onChange:l=>r(l.target.value)}),c&&o("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",tabIndex:-1,onClick:()=>i(l=>!l),children:a?o(to,{className:"h-3.5 w-3.5"}):o(Bt,{className:"h-3.5 w-3.5"})})]})})}function ig({field:e,value:t,onChange:r,disabled:n,translationFn:s}){return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("textarea",{className:kt+" resize-y min-h-[60px]",value:t==null?"":String(t),placeholder:e.placeholder,rows:e.rows??3,maxLength:e.maxLength,disabled:n||e.disabled,onChange:a=>r(a.target.value)})})}function lg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=t==null,i=e.nullable===!0,c=a?e.default??e.min:Number(t),l=e.showValue!==!1,u=e.nullLabel??"Auto",d=n||e.disabled,p=e.displayScale??1,h=e.min/p,g=e.max/p,b=c/p,v=(e.step??1)/p;if(i&&a)return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("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:d,onClick:()=>r(e.default??e.min),children:[u," — click to set manually"]})});const y=e.showStepper===!0&&l,x=w=>{const N=c+w*(e.step??1),S=Math.min(e.max,Math.max(e.min,N));S!==c&&r(S)},k="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 o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[m("div",{className:"flex min-w-0 flex-1 basis-[160px] items-center gap-2",children:[o("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:h}),o("input",{type:"range",className:"min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50",min:h,max:g,step:v,value:b,disabled:d,onChange:w=>r(Number(w.target.value)*p)}),o("span",{className:"text-[10px] text-foreground-subtle tabular-nums shrink-0",children:g})]}),(l||i||e.unit)&&m("div",{className:"flex shrink-0 items-center gap-2",children:[y&&o("button",{type:"button",className:k,disabled:d||c<=e.min,onClick:()=>x(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:o(ai,{className:"h-3 w-3"})}),l&&o("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:h,max:g,step:v,value:b,disabled:d,onChange:w=>{if(w.target.value===""){r(i?null:e.min);return}const N=Number(w.target.value)*p,S=e.step??1,M=N-e.min,P=e.min+Math.round(M/S)*S;r(Math.min(e.max,Math.max(e.min,P)))}}),y&&o("button",{type:"button",className:k,disabled:d||c>=e.max,onClick:()=>x(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:o(zt,{className:"h-3 w-3"})}),e.unit&&o("span",{className:"text-[10px] text-foreground-subtle",children:e.unit}),i&&o("button",{className:"text-[10px] text-foreground-subtle hover:text-primary transition-colors",title:`Reset to ${u}`,disabled:d,onClick:()=>r(null),children:u})]})]})})}function cg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=Array.isArray(t)?t:[],[i,c]=E(""),l=W(null),u=R(g=>{const b=g.trim();!b||a.includes(b)||e.maxTags!==void 0&&a.length>=e.maxTags||(r([...a,b]),c(""))},[a,e.maxTags,r]),d=g=>r(a.filter(b=>b!==g)),p=g=>{g.key==="Enter"||g.key===","?(g.preventDefault(),u(i)):g.key==="Backspace"&&i===""&&a.length>0&&d(a[a.length-1])},h=n||e.disabled;return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("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",h?"opacity-50 cursor-not-allowed":""].join(" "),onClick:()=>!h&&l.current?.focus(),children:[a.map(g=>m("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[g,!h&&o("button",{type:"button",onClick:()=>d(g),className:"hover:text-danger",children:o(_e,{className:"h-2.5 w-2.5"})})]},g)),o("input",{ref:l,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:h,list:`tags-suggestions-${e.key}`,onChange:g=>c(g.target.value),onKeyDown:p,onBlur:()=>{i.trim()&&u(i)}}),e.suggestions&&o("datalist",{id:`tags-suggestions-${e.key}`,children:e.suggestions.map(g=>o("option",{value:g},g))})]})})}function ug({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const{nodes:a}=io(),i=typeof t=="string"?t:"",c=e.showOffline?a:a.filter(l=>l.isOnline);return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("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:l=>r(l.target.value),disabled:n,children:[o("option",{value:"",children:"Select node…"}),c.map(l=>m("option",{value:l.id,disabled:!l.isOnline,children:[l.shortName,l.isOnline?"":" (offline)"]},l.id))]})})}function dg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const{nodes:a}=io(),i=new Set(Array.isArray(t)?t.map(String):[]),c=e.showOffline?a:a.filter(u=>u.isOnline),l=u=>{const d=new Set(i);d.has(u)?d.delete(u):d.add(u),r([...d])};return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("div",{className:"flex flex-wrap gap-1.5",children:c.map(u=>{const d=i.has(u.id);return o("button",{type:"button",onClick:()=>l(u.id),disabled:n||!u.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${d?"border-primary bg-primary/10 text-primary":"border-border bg-surface text-foreground-subtle hover:bg-surface-hover"} ${u.isOnline?"":"opacity-50 cursor-not-allowed"}`,children:u.shortName},u.id)})})})}function pg({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=t==null?"#000000":String(t);return m(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[m("div",{className:"flex items-center gap-2",children:[o("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:n||e.disabled,onChange:i=>r(i.target.value)}),o("input",{type:"text",className:kt+" flex-1 font-mono",value:a,placeholder:"#000000",disabled:n||e.disabled,onChange:i=>r(i.target.value)})]}),e.presets&&e.presets.length>0&&o("div",{className:"flex gap-1.5 mt-1.5",children:e.presets.map(i=>o("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:n||e.disabled,title:i,onClick:()=>r(i)},i))})]})}function fg({field:e,value:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i,externalProbe:c}){const[l,u]=E("idle"),[d,p]=E(null),h=c?.status??l,g=c?.result??d,b=!!a||!!i,v=R(async()=>{if(b){u("probing"),p(null);try{const k=a?await a(e.key,t):await i("test-probe",e.key,t),w=k&&typeof k=="object"?k:{status:"error",error:"Probe handler returned no result"};p(w),u(w.status==="ok"?"ok":"error")}catch(k){p({status:"error",error:k instanceof Error?k.message:String(k)}),u("error")}}},[a,i,e.key,t,b]),y=h==="probing"?"border-primary/40 bg-primary/10 text-primary":h==="ok"?"border-success/40 bg-success/10 text-success hover:bg-success/15":h==="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",x=h==="probing"?o(Fe,{className:"h-3 w-3 animate-spin"}):h==="ok"?o(ep,{className:"h-3 w-3"}):h==="error"?o($t,{className:"h-3 w-3"}):o(pi,{className:"h-3 w-3"});return m(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:[m("div",{className:"@container flex items-center gap-2",style:{containerType:"inline-size"},children:[m("button",{type:"button",onClick:v,title:"Test",disabled:e.disabled||h==="probing"||!b||!t,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 ${y}`,children:[x,o("span",{className:"hidden @[280px]:inline",children:"Test"})]}),o("input",{type:e.inputType??"url",className:kt+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:n||e.disabled,onChange:k=>{r(k.target.value),l!=="idle"&&(u("idle"),p(null))}})]}),h==="ok"&&g?.labels&&g.labels.length>0&&o("div",{className:"flex flex-wrap gap-1 mt-1.5",children:g.labels.map((k,w)=>o("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:k},w))}),h==="error"&&g?.error&&o("p",{className:"text-xs text-danger mt-1 truncate",title:g.error,children:g.error})]})}function mg({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a}){const[i,c]=E(e.defaultCollapsed??!1),l=e.style==="accordion";return o("div",{className:e.span===2?"col-span-2":e.span===3?"col-span-3":e.span===4?"col-span-4":"col-span-1",children:m("div",{className:"rounded-lg border border-border bg-surface/50 overflow-hidden",children:[m("div",{className:["px-3 py-2 flex items-center justify-between",l?"cursor-pointer hover:bg-surface":""].join(" "),onClick:l?()=>c(u=>!u):void 0,children:[o("span",{className:"text-xs font-semibold text-foreground",children:qe(e.label,s)}),l&&o("span",{className:"text-foreground-subtle text-xs",children:i?"▸":"▾"})]}),!i&&o("div",{className:"px-3 pb-3 grid grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(u=>o(ir,{field:u,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a},u.key))})]})})}function hg({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i}){const[c,l]=E(e.tabs[0]?.id??""),u=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:m("div",{className:u,children:[e.label&&o("div",{className:jr,children:qe(e.label,s)}),m("div",{className:"rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",children:[o("div",{className:"flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40",role:"tablist",children:e.tabs.map(d=>{const p=d.id===c;return m("button",{type:"button",role:"tab","aria-selected":p,onClick:()=>l(d.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${p?"bg-primary text-primary-foreground font-medium shadow-sm":"bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground"}`,children:[o("span",{children:qe(d.label,s)}),d.badge&&o("span",{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${p?"bg-primary-foreground/20 text-primary-foreground":"bg-primary/10 text-primary"}`,children:d.badge})]},d.id)})}),e.tabs.map(d=>d.id!==c?null:o("div",{role:"tabpanel",className:"px-3 pb-3 pt-2 grid grid-cols-2 gap-x-4 gap-y-3",children:d.fields.map((p,h)=>{const g="key"in p&&typeof p.key=="string"?p.key:`__${d.id}__${h}`;return o(ir,{field:p,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i},g)})},d.id))]})]})}function gg({span:e}){return o("div",{className:e===2?"col-span-2":e===3?"col-span-3":e===4?"col-span-4":"col-span-full",children:o("hr",{className:"border-border"})})}var gs={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 bg(e){if(typeof window>"u"||typeof DOMParser>"u")return"";const t=new Set(["A","UL","OL","LI","STRONG","EM","CODE","BR","P","SPAN"]),r=new DOMParser().parseFromString(`<div>${e}</div>`,"text/html"),n=r.body.firstElementChild;if(!n)return"";const s=a=>{const i=Array.from(a.children);for(const c of i){if(!t.has(c.tagName)){const u=r.createTextNode(c.textContent??"");c.replaceWith(u);continue}const l=c.tagName==="A"?new Set(["href"]):new Set;for(const u of Array.from(c.attributes))l.has(u.name)||c.removeAttribute(u.name);if(c.tagName==="A"){const u=c.getAttribute("href")??"";!/^https?:\/\//i.test(u)&&!u.startsWith("mailto:")?c.removeAttribute("href"):(c.setAttribute("target","_blank"),c.setAttribute("rel","noopener noreferrer"))}s(c)}};return s(n),n.innerHTML}function vg({field:e}){const t=gs[e.variant??"info"]??gs.info,r=e.format==="html";return o("div",{className:"col-span-full",children:m("div",{className:`rounded-md border-l-4 px-3 py-2.5 ${t.border} ${t.bg}`,children:[e.label&&o("p",{className:`text-xs font-semibold mb-0.5 ${t.text}`,children:e.label}),r?o("div",{className:"text-xs text-foreground-subtle leading-relaxed info-html-content",dangerouslySetInnerHTML:{__html:bg(e.content)}}):o("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}var bs={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function yg(e){if(!Number.isFinite(e)||e<0)return"—";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60),n=t%60;return n===0?`${r}m`:`${r}m ${n}s`}function xg(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function wg({kind:e,value:t}){return t==null||t===""?o("span",{className:"text-foreground-subtle/60",children:"—"}):e==="monospace"?o("span",{className:"font-mono text-[11px]",children:String(t)}):e==="status"?m("span",{className:"inline-flex items-center gap-1.5",children:[o("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${bs[String(t).toLowerCase()]??bs.unknown}`}),o("span",{children:String(t)})]}):e==="duration"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:yg(t)}):e==="timestamp"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:xg(t)}):o("span",{children:String(t)})}function kg({field:e}){const t=e.value??[],r=e.description;return m("div",{className:"col-span-full",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1",children:e.label}),r&&o("p",{className:"text-xs text-foreground-subtle mb-2",children:r}),t.length===0?o("div",{className:"rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle",children:e.emptyMessage??"No entries"}):o("div",{className:"rounded-md border border-border overflow-hidden",children:m("table",{className:"w-full text-xs",children:[o("thead",{className:"bg-surface-subtle border-b border-border",children:o("tr",{children:e.columns.map(n=>o("th",{className:"px-3 py-1.5 text-left font-medium text-foreground-subtle",style:n.width?{width:n.width}:void 0,children:n.label},n.key))})}),o("tbody",{className:"divide-y divide-border",children:t.map((n,s)=>o("tr",{className:"hover:bg-surface-hover/40",children:e.columns.map(a=>o("td",{className:"px-3 py-1.5 align-top text-foreground",children:o(wg,{kind:a.kind,value:n[a.key]})},a.key))},s))})]})})]})}function Ng({field:e,value:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i}){const c=Array.isArray(t)?t:[],l=e.minRows??0,u=e.maxRows??Number.POSITIVE_INFINITY,d=(y,x,k)=>{const w=c.slice();w[y]={...w[y]??{},[x]:k},r(w)},p=y=>{c.length<=l||r(c.filter((x,k)=>k!==y))},h=()=>{if(c.length>=u)return;const y=e.defaultItem??{};r([...c,{...y}])},g=(y,x)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(k,w)=>{const N=y[w];return N==null||N===""?"—":String(N)}):`Row ${x+1}`,b=c.length>l,v=c.length<u;return m("div",{className:"col-span-full space-y-2",children:[m("div",{className:"space-y-0.5",children:[e.label&&o("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:qe(e.label,s)}),e.description&&o("p",{className:"text-[11px] text-foreground-subtle",children:qe(e.description,s)})]}),c.length===0?o("div",{className:"rounded-md border border-dashed border-border bg-background px-3 py-3 text-center text-[11px] text-foreground-subtle",children:e.emptyMessage??"No entries"}):o("div",{className:"space-y-2",children:c.map((y,x)=>m("div",{className:"rounded-md border border-border bg-background",children:[m("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[o("span",{className:"text-xs font-medium text-foreground",children:g(y,x)}),m("button",{type:"button",onClick:()=>p(x),disabled:n||!b,className:"inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-30 disabled:cursor-not-allowed",title:b?"Remove this row":`At least ${l} row(s) required`,children:[o(ai,{className:"h-3 w-3"}),"Remove"]})]}),o("div",{className:"grid grid-cols-1 @[420px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(k=>o(ir,{field:k,values:y,onChange:(w,N)=>d(x,w,N),disabled:n,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},k.key))})]},x))}),m("div",{children:[m("button",{type:"button",onClick:h,disabled:n||!v,className:"inline-flex items-center gap-1 rounded border border-border bg-surface px-3 py-1 text-[11px] font-medium text-foreground hover:border-primary/40 hover:bg-primary/5 disabled:opacity-30 disabled:cursor-not-allowed",children:[o(zt,{className:"h-3 w-3"}),e.addLabel??"Add"]}),!v&&Number.isFinite(u)&&m("span",{className:"ml-2 text-[10px] text-foreground-subtle",children:["(limit: ",u,")"]})]})]})}function Sg({field:e,disabled:t,onAction:r}){const[n,s]=E(!1),a=Gr(),i=async()=>{if(!(e.confirmMessage&&!await a({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"}))&&r){s(!0);try{await r(e.action,e.key)}finally{s(!1)}}},c={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 o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,children:o("button",{onClick:i,disabled:t||n,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${c[e.variant??"default"]??c.default}`,children:n?"Processing...":e.buttonLabel})})}function gl(e,t){const r={...e.paramsStatic??{}};if(e.paramsFromForm)for(const[n,s]of Object.entries(e.paramsFromForm)){const a=t[s];a!=null&&a!==""&&(r[n]=a)}return r}function Cg({field:e,value:t,values:r,onChange:n,disabled:s,onAction:a}){const[i,c]=E(!1),[l,u]=E(null),[d,p]=E(null),h=gl(e,r),g=Object.keys(e.paramsFromForm??{}).some(x=>h[x]===void 0);Q(()=>{if(!a||g){p(null),u(null);return}let x=!1;return c(!0),u(null),a(e.action,e.key,h).then(k=>{if(x)return;const w=k;let N=[];if(Array.isArray(w))N=w;else if(w&&typeof w=="object")for(const S of Object.keys(w)){const M=w[S];if(Array.isArray(M)){N=M;break}}p(N)}).catch(k=>{x||(u(k instanceof Error?k.message:String(k)),p([]))}).finally(()=>{x||c(!1)}),()=>{x=!0}},[(e.refreshOn??Object.values(e.paramsFromForm??{})).map(x=>`${x}=${JSON.stringify(r[x])}`).join("|"),a,e.action,e.key]);const b=e.mapOption.value,v=e.mapOption.label,y=e.mapOption.description;return o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,children:g?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyParamsMessage??"Fill the prerequisite fields above first."}):i?m("div",{className:"flex items-center gap-2 text-[11px] text-foreground-subtle",children:[o(Fe,{className:"h-3 w-3 animate-spin"})," Loading options…"]}):l?o("div",{className:"text-[11px] text-danger",children:l}):d&&d.length===0?o("div",{className:"text-[11px] text-foreground-subtle italic",children:e.emptyResultsMessage??"No options returned."}):(()=>{const x=(d??[]).some(k=>{const w=k[b];return w===""||w===void 0});return m("select",{className:"w-full rounded-md border border-border bg-surface px-2 py-1.5 text-xs text-foreground",value:typeof t=="string"?t:"",disabled:s,onChange:k=>n(k.target.value),children:[!x&&o("option",{value:"",children:"— Select —"}),(d??[]).map((k,w)=>{const N=k[b],S=k[v],M=y?k[y]:void 0,P=typeof N=="string"&&N!==""?N:`row-${w}`;return m("option",{value:typeof N=="string"?N:String(N??""),children:[typeof S=="string"?S:String(S??P),M!==void 0?` (${String(M)})`:""]},P)})]})})()})}function Mg({field:e,values:t,disabled:r,onAction:n}){const[s,a]=E(!1),[i,c]=E(null),l=Gr(),u=async()=>{if(e.confirmMessage&&!await l({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant==="danger"?"danger":"default"})||!n)return;const p=gl(e,t);a(!0),c(null);try{const h=await n(e.action,e.key,p),g=typeof h=="object"&&h!==null?h:null;c({kind:"ok",text:e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(b,v)=>{const y=g?.[v];return y===void 0?"":String(y)}):"Done."})}catch(h){c({kind:"error",text:h instanceof Error?h.message:String(h)})}finally{a(!1)}},d={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 o(Ae,{label:e.label,description:e.description,required:e.required,span:e.span,children:m("div",{className:"flex flex-col gap-1.5",children:[o("button",{onClick:u,disabled:r||s,className:`inline-flex w-fit items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${d[e.variant??"default"]??d.default}`,children:s?"Working…":e.buttonLabel}),i&&o("div",{className:`text-[11px] ${i.kind==="ok"?"text-emerald-700 dark:text-emerald-300":"text-danger"}`,children:i.text})]})})}function Eg({field:e}){const t=yh();return o(Zh,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})}function Ag(e,t){if(e==null)return"—";if(typeof e=="boolean")return e?"yes":"no";if(typeof e=="number"){const r=Number.isInteger(e)?String(e):e.toFixed(2);return t?`${r} ${t}`:r}return typeof e=="string"?e:JSON.stringify(e)}function Pg({field:e,values:t,onAction:r,translationFn:n}){const s="key"in e?e.key:void 0;if(!s)return null;const a=t[s],i=a!==void 0?a:"default"in e?e.default:void 0,c=Ag(i,"unit"in e?e.unit:void 0),l="label"in e?e.label:void 0,u="description"in e?e.description:void 0,d="span"in e?e.span:void 0,p="actions"in e?e.actions??[]:[];return o(Ae,{label:l,description:u,span:d,translationFn:n,children:m("div",{className:"flex items-stretch gap-1",children:[o("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:c}),p.length>0&&o("div",{className:"flex items-center gap-1",children:p.map(h=>o(_g,{action:h,fieldKey:s,value:i,onAction:r},h.action))})]})})}function Rg({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return o(dt,{className:t});case"refresh-cw":return o(Br,{className:t});case"external-link":return o(eo,{className:t});case"trash-2":return o(et,{className:t});case"download":return o(Nn,{className:t});case"upload":return o(di,{className:t});default:return o(no,{className:t})}}function _g({action:e,fieldKey:t,value:r,onAction:n}){const s=Gr(),[a,i]=E(!1),c=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 o("button",{type:"button",onClick:async()=>{if(!(e.confirmMessage&&!await s({title:e.tooltip,message:e.confirmMessage,variant:e.variant==="danger"?"danger":"default"}))){if(e.action==="copy-value"){try{await navigator.clipboard.writeText(typeof r=="string"?r:String(r))}catch{}return}if(n){i(!0);try{await n(e.action,t)}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 ${c}`,children:o(Rg,{name:e.icon})})}function Ig(e){return"multiple"in e&&e.multiple!=null}function Tg({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,externalProbe:i,allFields:c,onAction:l}){const u=e.multiple,d=u.min,p=u.max,h=t[e.key],g=[...Array.isArray(h)?h:h!=null?[h]:[]],b=u.itemDefault!==void 0?u.itemDefault:"default"in e&&e.default!==void 0?e.default:"";for(;g.length<d;)g.push(b);const v=N=>r(e.key,[...N]),y=(N,S)=>{const M=[...g];M[N]=S,v(M)},x=()=>{g.length>=p||v([...g,b])},k=N=>{g.length<=d||v(g.filter((S,M)=>M!==N))},w=()=>{const{multiple:N,...S}=e;return{...S,...{label:void 0,description:void 0,required:!1}}};return o(Ae,{label:e.label,description:e.description,required:d>0?e.required:!1,span:e.span,translationFn:s,children:m("div",{className:"space-y-2",children:[g.map((N,S)=>{const M=u.itemLabel?.replace("${n}",String(S+1));return m("div",{className:"space-y-1",children:[M&&o("div",{className:jr,children:M}),m("div",{className:"flex items-center gap-2",children:[o("div",{className:"flex-1 min-w-0",children:o(ir,{field:w(),values:{...t,[e.key]:N},onChange:(P,A)=>y(S,A),disabled:n,translationFn:s,onTestField:a,onAction:l,allFields:c})}),g.length>d&&o("button",{type:"button",onClick:()=>k(S),disabled:n,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:o(et,{className:"h-3.5 w-3.5"})})]})]},S)}),m("div",{className:"flex items-center justify-between pt-1",children:[g.length<p?m("button",{type:"button",onClick:x,disabled:n,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:[o(zt,{className:"h-3 w-3"}),u.addLabel??"Add"]}):o("span",{}),m("span",{className:"text-[10px] text-foreground-subtle tabular-nums",children:[g.length,"/",p]})]})]})})}function Dg(e,t,r){if(!("showWhen"in e)||!e.showWhen)return!0;const n=e.showWhen,s=t[n.field],a=r?.find(l=>"key"in l&&l.key===n.field),i=a&&"default"in a?a.default:void 0,c=s!==void 0?s:i;return n.equals!==void 0?c===n.equals:n.notEquals!==void 0?c!==n.notEquals:n.in!==void 0?n.in.includes(c):n.notIn!==void 0?!n.notIn.includes(c):n.includes!==void 0?Array.isArray(c)&&c.includes(n.includes):n.notIncludes!==void 0?!Array.isArray(c)||!c.includes(n.notIncludes):!0}function ir({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,externalProbe:i,allFields:c,onAction:l}){if(Ig(e))return o(Tg,{field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,externalProbe:i,allFields:c,onAction:l});if("readonlyField"in e&&e.readonlyField===!0)return o(Pg,{field:e,values:t,onAction:l,translationFn:s});if(!Dg(e,t,c))return null;const u=t[e.key],d=u!==void 0?u:"default"in e?e.default:void 0,p=g=>r(e.key,g),h=vh(e.type);switch(e.type){case"text":return o(tg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"number":return o(rg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"boolean":return o(ng,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"select":return o(og,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"multiselect":return o(sg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"password":return o(ag,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"textarea":return o(ig,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"slider":return o(lg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"tags":return o(cg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"color":return o(pg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"node-select":return o(ug,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"node-multiselect":return o(dg,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"probe":return o(fg,{field:e,value:d,onChange:p,disabled:n,translationFn:s,onTestField:a,onAction:l,externalProbe:i});case"group":return o(mg,{field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a});case"sub-tabs":return o(hg,{field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:l});case"separator":return o(gg,{});case"info":return o(vg,{field:e});case"object-array":return o(kg,{field:e});case"editable-array":return o(Ng,{field:e,value:d,onChange:p,disabled:n,translationFn:s,onTestField:a,onAction:l});case"button":return o(Sg,{field:e,disabled:n,onAction:l});case"addon-action-select":return o(Cg,{field:e,value:d,values:t,onChange:p,disabled:n,onAction:l});case"addon-action-button":return o(Mg,{field:e,values:t,disabled:n,onAction:l});case"widget":return o(Eg,{field:e});default:return h?o(h,{field:e,value:d,onChange:p,disabled:n}):null}}function Lg(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function qe(e,t){if(e!==void 0)return t&&Lg(e)?t(e):e}function Og({section:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,probeResults:i}){const[c,l]=E(e.defaultCollapsed??!1),u=e.style==="accordion",d=e.columns??2,p=d===1?"grid-cols-1":d===3?"grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3":d===4?"grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4":"grid-cols-1 @[640px]:grid-cols-2";return m("div",{className:"@container rounded-lg border border-border bg-surface p-3",style:{containerType:"inline-size"},children:[m("div",{className:["flex items-center justify-between mb-2",u?"cursor-pointer":""].join(" "),onClick:u?()=>l(h=>!h):void 0,children:[m("div",{children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:qe(e.title,s)}),e.description&&o("p",{className:"text-[10px] text-foreground-subtle mt-0.5",children:qe(e.description,s)})]}),u&&o("span",{className:"text-foreground-subtle text-xs ml-2",children:c?"▸":"▾"})]}),!c&&o("div",{className:`grid ${p} gap-x-3 gap-y-2.5`,children:e.fields.map(h=>o(ir,{field:h,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,externalProbe:i?.[h.key]},h.key))})]})}function $g({schema:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,probeResults:i,onClearProbe:c}){const l=(u,d)=>{r({...t,[u]:d}),c?.(u)};return o("div",{className:"space-y-4",children:e.sections.map(u=>o(Og,{section:u,values:t,onChange:l,disabled:n,translationFn:s,onTestField:a,probeResults:i},u.id))})}var Bg=({open:e})=>o("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:o("polyline",{points:"9 18 15 12 9 6"})});function vs(e){const t={};if(!e)return t;for(const r of e.sections)for(const n of r.fields){if(n.type==="separator"||n.type==="info"||n.type==="button"||n.type==="group")continue;const s=n.key;t[s]=n.value}return t}function zg(e){return{...e,sections:e.sections.map(t=>({...t,fields:t.fields.map(r=>{if(r.type==="separator"||r.type==="info"||r.type==="button"||r.type==="group")return r;const{value:n,...s}=r;return s})}))}}function I5({trpc:e,addonId:t,nodeId:r,title:n,disabled:s,onAfterChange:a,refreshToken:i,collapsible:c,defaultOpen:l,mode:u,onOverrideChange:d}){const p=u??"persist",[h,g]=E(null),[b,v]=E(!0),[y,x]=E(null),[k,w]=E(!1),[N,S]=E(l??!1),[M,P]=E({}),[A,V]=E(null);Q(()=>{V(null),P({})},[e,t,r,i,p]),Q(()=>{let oe=!1;v(!0),x(null);const J=p==="override"&&Object.keys(M).length>0?M:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:r,...J?{overlay:J}:{}}).then(K=>{oe||(g(K),J||V(vs(K)),v(!1))}).catch(K=>{oe||(x(K instanceof Error?K.message:String(K)),v(!1))}),()=>{oe=!0}},[e,t,r,i,p,JSON.stringify(M)]);const H=q(()=>vs(h),[h]),ae=q(()=>h?zg(h):null,[h]),pe=async oe=>{if(p==="override"){const K=A??H,fe={};for(const D of Object.keys(oe))oe[D]!==K[D]&&(fe[D]=oe[D]);const Z={...K,...fe};P(fe),d?.(fe,Z);return}const J={};for(const K of Object.keys(oe))oe[K]!==H[K]&&(J[K]=oe[K]);if(Object.keys(J).length!==0){w(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:r,patch:J}),g(await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:r})),a?.()}catch(K){x(K instanceof Error?K.message:String(K))}finally{w(!1)}}};if(b)return m("div",{className:"text-xs text-foreground-subtle animate-pulse",children:["Loading ",n??t,"…"]});if(y)return m("div",{className:"text-xs text-red-400",children:[n??t,": ",y]});if(!h||!ae)return m("div",{className:"text-xs text-foreground-subtle",children:[n??t," not available on ",r,"."]});const ne=p==="override"?{...H,...M}:H,se=m(we,{children:[p==="override"?o("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,o($g,{schema:ae,values:ne,onChange:pe,disabled:s===!0||k})]});return c===!0?m("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[m("button",{type:"button",onClick:()=>S(oe=>!oe),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":N,children:[o(Bg,{open:N}),o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide flex-1",children:n??t}),o("span",{className:"text-[10px] text-foreground-subtle",children:N?"hide":"edit"})]}),N?o("div",{className:"border-t border-border px-4 py-3",children:se}):null]}):n?m("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[o("div",{className:"border-b border-border px-4 py-2",children:o("h3",{className:"text-xs font-semibold text-foreground uppercase tracking-wide",children:n})}),o("div",{className:"px-4 py-3",children:se})]}):o("div",{children:se})}function Fg({detections:{motion:e,motionRaw:t,detection:r,phase:n},showMotionZones:s=!0,showMotionRaw:a=!0,showDetections:i=!0,showPhaseIndicator:c=!0}){const l=s&&e&&e.zones.length>0,u=a&&t&&t.boxes.length>0,d=i&&r&&r.detections.length>0;return!l&&!u&&!d&&!c?null:m("div",{className:"absolute inset-0 pointer-events-none z-10",children:[c&&o(Gg,{phase:n}),u&&o(Qg,{raw:t}),l&&o(jg,{motion:e}),d&&o(Ug,{detections:r.detections,frameWidth:r.frameWidth,frameHeight:r.frameHeight})]})}function Gg({phase:e}){const t=ua(e);return m("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:[o("span",{className:`w-2 h-2 rounded-full ${t.dotClass}`}),o("span",{className:"text-[10px] font-semibold text-white uppercase tracking-wider",children:t.label})]})}function Qg({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:o(we,{children:e.boxes.map((t,r)=>{const[n,s,a,i]=t.bbox,c=n/e.frameWidth*100,l=s/e.frameHeight*100,u=(a-n)/e.frameWidth*100,d=(i-s)/e.frameHeight*100,p=Math.max(.05,Math.min(.25,t.changeScore*.3));return o("div",{className:"absolute rounded-sm",style:{left:`${c}%`,top:`${l}%`,width:`${u}%`,height:`${d}%`,backgroundColor:`rgba(239, 68, 68, ${p})`}},`mr-${r}`)})})}function jg({motion:e}){return e.frameWidth===0||e.frameHeight===0?null:o(we,{children:e.zones.filter(t=>t.w*t.h/(e.frameWidth*e.frameHeight)<.9).map((t,r)=>{const n=Math.max(.15,Math.min(.5,t.intensity/255));return o("div",{className:"absolute rounded-sm",style:{left:`${t.x/e.frameWidth*100}%`,top:`${t.y/e.frameHeight*100}%`,width:`${t.w/e.frameWidth*100}%`,height:`${t.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${n})`,backgroundColor:`rgba(250, 204, 21, ${n*.15})`}},`mz-${r}`)})})}function Ug({detections:e,frameWidth:t,frameHeight:r}){return t===0||r===0?null:o(we,{children:e.map(n=>{const{x:s,y:a,width:i,height:c}=n.bbox,l=s/t*100,u=a/r*100,d=i/t*100,p=c/r*100,h=je(n.macroClass),g=[`${n.macroClass} ${(n.score*100).toFixed(0)}%`];for(const b of n.labels)g.push(b.label);return o("div",{className:"absolute border-2 rounded-sm",style:{left:`${l}%`,top:`${u}%`,width:`${d}%`,height:`${p}%`,borderColor:h},children:o("div",{className:"absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap",style:{backgroundColor:h},children:g.join(" | ")})},`det-${n.id}`)})})}function Hg(e){const t={};if(typeof window<"u"){if(e){const n=e.getBoundingClientRect();n.width>0&&n.height>0&&(t.viewportWidth=Math.round(n.width),t.viewportHeight=Math.round(n.height))}t.viewportWidth===void 0&&(t.viewportWidth=window.innerWidth,t.viewportHeight=window.innerHeight),t.devicePixelRatio=window.devicePixelRatio||1;const r=navigator.connection;r?.downlink&&r.downlink>0&&(t.downlinkMbps=r.downlink)}return t}var Vg=3e3,qg=5;function Wg({serverUrl:e,streamKey:t,label:r,autoPlay:n=!0,muted:s=!0,showControls:a=!0,className:i="",onStateChange:c,onError:l,overlay:u,createSession:d,sendAnswer:p,closeSession:h,hintsOverride:g}){const b=W(null),v=W(null),y=W(null),x=W(new Set),k=W(null),w=W(null),N=W(0),S=W(!0),[M,P]=E("idle"),[A,V]=E(""),[H,ae]=E(s),[pe,ne]=E(!1),[se,oe]=E(!1),J=W(null),K=W(!1);(p||d)&&(K.current=!0);const fe=K.current,Z=R(ee=>{P(ee),c?.(ee)},[c]),D=R(()=>{if(k.current?.abort(),k.current=null,w.current&&(clearTimeout(w.current),w.current=null),y.current&&(y.current.close(),y.current=null),h&&x.current.size>0){for(const ee of x.current)h(ee).catch(()=>{});x.current.clear()}b.current&&(b.current.srcObject=null)},[h]),F=R(async()=>{if(!S.current||!d||!p)return;D(),Z("connecting");const ee=new AbortController;k.current=ee;try{const{sessionId:he,sdpOffer:ke}=await d({...Hg(v.current),...g});if(x.current.add(he),!S.current||ee.signal.aborted){h?.(he).catch(()=>{}),x.current.delete(he);return}const Ne=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});y.current=Ne;const Ie=new MediaStream;Ne.ontrack=z=>{console.debug("[WebRTC] ontrack",z.track.kind,z.track.readyState),Ie.addTrack(z.track),b.current&&(b.current.srcObject=Ie,b.current.play().catch(()=>{}))},Ne.oniceconnectionstatechange=()=>{if(!S.current)return;const z=Ne.iceConnectionState;console.debug("[WebRTC] ICE state:",z),z==="connected"||z==="completed"?(N.current=0,Z("playing"),b.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),b.current.play().catch(()=>{}))):(z==="failed"||z==="disconnected"||z==="closed")&&(Z("disconnected"),L())},Ne.onicecandidateerror=z=>{console.debug("[WebRTC] ICE candidate error:",z)},console.debug("[WebRTC] Setting remote description (server offer)..."),await Ne.setRemoteDescription({type:"offer",sdp:ke});const T=await Ne.createAnswer();if(await Ne.setLocalDescription(T),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await ys(Ne),!S.current)return;const le=(Ne.localDescription?.sdp??"").split(`
|
|
77
|
+
`).filter(z=>z.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:le,sessionId:he.slice(0,8)}),await p(he,Ne.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ge=Ne,ve=()=>{const z=ge.connectionState;if(z==="closed"||z==="failed")return;const re=b.current;re&&re.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ge.iceConnectionState})`)};setTimeout(ve,3e3),setTimeout(ve,8e3)}catch(he){if(!S.current)return;const ke=he instanceof Error?he.message:String(he);V(ke),Z("error"),l?.(ke),L()}},[e,t,d,p,D,Z,l,g]),O=R(async()=>{if(S.current){D(),Z("connecting");try{const ee=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});y.current=ee,ee.addTransceiver("video",{direction:"recvonly"}),ee.addTransceiver("audio",{direction:"recvonly"});const he=new MediaStream;ee.ontrack=le=>{he.addTrack(le.track),b.current&&(b.current.srcObject=he,b.current.play().catch(()=>{}))},ee.oniceconnectionstatechange=()=>{if(!S.current)return;const le=ee.iceConnectionState;le==="connected"||le==="completed"?(N.current=0,Z("playing"),b.current?.paused&&b.current.play().catch(()=>{})):(le==="failed"||le==="disconnected"||le==="closed")&&(Z("disconnected"),L())};const ke=await ee.createOffer();if(await ee.setLocalDescription(ke),await ys(ee),!S.current)return;const Ne=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,Ie=await fetch(Ne,{method:"POST",headers:{"Content-Type":"application/sdp"},body:ee.localDescription?.sdp??""});if(!Ie.ok)throw new Error(`WHEP ${Ie.status}: ${Ie.statusText}`);const T=await Ie.text();await ee.setRemoteDescription({type:"answer",sdp:T})}catch(ee){if(!S.current)return;const he=ee instanceof Error?ee.message:String(ee);V(he),Z("error"),l?.(he),L()}}},[e,t,D,Z,l]),ie=fe?F:O,_=W(()=>{});_.current=ie;const L=R(()=>{S.current&&(N.current>=qg||(N.current+=1,w.current=setTimeout(()=>{S.current&&_.current()},Vg)))},[]);Q(()=>(S.current=!0,N.current=0,n&&ie(),()=>{S.current=!1,D()}),[e,t]);const G=W(!1);Q(()=>{!n||!fe||!d||!p||G.current||y.current||(G.current=!0,ie())},[n,fe,d,p,ie]);const B=()=>{N.current=0,ie()},te=()=>{b.current&&(b.current.muted=!b.current.muted,ae(b.current.muted))},X=async()=>{if(v.current)try{document.fullscreenElement?await document.exitFullscreen():await v.current.requestFullscreen()}catch(ee){console.warn(`Fullscreen toggle failed: ${ee instanceof Error?ee.message:ee}`)}},Le=()=>{if(!b.current)return;const ee=document.createElement("canvas");ee.width=b.current.videoWidth||1280,ee.height=b.current.videoHeight||720;const he=ee.getContext("2d");if(!he)return;he.drawImage(b.current,0,0);const ke=document.createElement("a");ke.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,ke.href=ee.toDataURL("image/jpeg",.92),ke.click()};Q(()=>{const ee=()=>ne(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",ee),()=>document.removeEventListener("fullscreenchange",ee)},[]);const Oe=()=>{oe(!0),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>oe(!1),3e3)};return m("div",{ref:v,className:`relative bg-black overflow-hidden group ${i}`,onMouseMove:Oe,onMouseEnter:Oe,children:[o("video",{ref:b,autoPlay:n,muted:H,playsInline:!0,className:"w-full h-full object-contain"}),r&&M==="playing"&&o("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:r}),u,M==="connecting"&&m("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[o("svg",{className:"h-6 w-6 text-white/60 animate-spin",viewBox:"0 0 24 24",fill:"none",children:o("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]"})}),o("span",{className:"text-xs text-white/60",children:"Connecting…"})]}),(M==="error"||M==="disconnected")&&m("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/70 gap-2",children:[o("svg",{className:"h-6 w-6 text-red-400",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o("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"})}),o("span",{className:"text-xs text-red-400 text-center px-4",children:M==="error"?A||"Connection failed":"Disconnected"}),o("button",{onClick:B,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"&&m("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 ${se?"opacity-100":"opacity-0"}`,children:[o("div",{className:"flex items-center gap-1",children:o(cn,{onClick:te,title:H?"Unmute":"Mute",children:H?m("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),o("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),o("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):m("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),o("path",{d:"M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07"})]})})}),m("div",{className:"flex items-center gap-1",children:[o(cn,{onClick:Le,title:"Take snapshot",children:m("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o("path",{d:"M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z"}),o("circle",{cx:"12",cy:"13",r:"4"})]})}),o(cn,{onClick:X,title:pe?"Exit fullscreen":"Fullscreen",children:pe?o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("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"})}):o("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o("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 cn({onClick:e,title:t,children:r}){return o("button",{onClick:e,title:t,className:"rounded-full p-1.5 text-white/80 hover:text-white hover:bg-white/20 transition-colors",children:r})}async function ys(e){if(e.iceGatheringState!=="complete")return new Promise(t=>{const r=()=>{e.iceGatheringState==="complete"&&(e.removeEventListener("icegatheringstatechange",r),t())};e.addEventListener("icegatheringstatechange",r),setTimeout(t,5e3)})}function Kg(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function Zg(e){const t=Math.floor(e/1e3);return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h${Math.floor(t%3600/60)}m`}function $n({className:e}){return o("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("polygon",{points:"5 3 19 12 5 21 5 3"})})}function Yg({className:e}){return o("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})})}function Xg({className:e}){return m("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),o("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),o("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),o("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function Jg({className:e}){return m("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor",children:[o("circle",{cx:"5",cy:"12",r:"2"}),o("circle",{cx:"12",cy:"12",r:"2"}),o("circle",{cx:"19",cy:"12",r:"2"})]})}function un({label:e,active:t,onClick:r}){return m("button",{type:"button",onClick:r,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:[o("span",{children:e}),o("span",{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?"bg-primary":"bg-foreground-subtle/30"} relative`,children:o("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?"left-2.5":"left-0.5"}`})})]})}function bl({className:e}){return m("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("polyline",{points:"23 4 23 10 17 10"}),o("polyline",{points:"1 20 1 14 7 14"}),o("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]})}function eb({className:e}){return m("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("line",{x1:"2",y1:"2",x2:"22",y2:"22"}),o("path",{d:"M10.41 10.41a2 2 0 11-2.83-2.83"}),o("line",{x1:"13.5",y1:"13.5",x2:"6",y2:"21"}),o("path",{d:"M18 12l-1.5-1.5"}),o("path",{d:"M21 15V5a2 2 0 00-2-2H5"}),o("path",{d:"M21 21H5a2 2 0 01-2-2V11"})]})}function T5({serverUrl:e,createSession:t,sendAnswer:r,closeSession:n,streams:s,activeStreamId:a,onStreamChange:i,deviceName:c,phase:l,pipelineMetrics:u,detections:d,defaultShowDetections:p=!0,defaultShowMotion:h=!1,streamStats:g,autoPlay:b=!1,showPlayStop:v=!1,snapshotSrc:y,snapshotLoading:x=!1,onRefreshSnapshot:k,showStreamStats:w=!1,children:N,extraOverlay:S,ptzAvailable:M=!1,ptzShown:P=!1,ptzOverlay:A,onPtzToggle:V,intercomAvailable:H=!1,intercomShown:ae=!1,onIntercomToggle:pe,chromeless:ne=!1,className:se}){const oe=jh(),[J,K]=E(b),[fe,Z]=E(p),[D,F]=E(h),[O,ie]=E(null),[_,L]=E(!1),G=W(null);Q(()=>{if(!_)return;function z(re){G.current&&!G.current.contains(re.target)&&L(!1)}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[_]);const B=a??O??s?.[0]?.id??"",te=s?.find(z=>z.id===B)??s?.[0],X=te?.inputFps!=null?{status:te.status??"unknown",inputFps:te.inputFps,bitrateKbps:te.bitrateKbps??0}:null,Le=z=>{ie(z),i?.(z),J&&v&&(K(!1),setTimeout(()=>K(!0),50))},Oe=q(()=>{const z=te?.target;if(z)return re=>t(z,re)},[t,te]),ee=s,he=()=>K(!0),ke=()=>K(!1),Ne=u?.phase??l,Ie=Ne==="active",T=!!d,le=T&&(fe||D),ge=M&&P&&!!A,ve=v?J:!0;return m("div",{className:`overflow-hidden ${ne?"":"rounded-xl border border-border bg-surface"} ${se??""}`,children:[m("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[m("div",{className:"flex items-center gap-2",children:[(g??X)&&o("span",{className:`w-2 h-2 rounded-full ${Kg((g??X).status)}`}),c&&o("span",{className:"text-xs font-medium text-foreground",children:c}),ee&&ee.length>1&&m("div",{className:"relative",children:[o("select",{"data-testid":"stream-profile-select",value:B,onChange:z=>Le(z.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:ee.map(z=>o("option",{value:z.id,children:z.label},z.id))}),o("span",{className:"pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle",children:o("svg",{className:"h-2.5 w-2.5",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o("polyline",{points:"3 4.5 6 7.5 9 4.5"})})})]})]}),m("div",{className:"flex items-center gap-1.5",children:[H&&m("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":ae?"true":"false",onClick:pe,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${ae?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:ae?"Close intercom":"Open intercom",children:[o(Xg,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:"Intercom"})]}),oe.map(z=>{const re=z.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return m("button",{type:"button","data-toolbar-button-id":z.id,"data-toolbar-button-active":z.active?"true":"false",onClick:z.onClick,disabled:z.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${z.active?re:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:z.title??z.label,children:[z.icon,o("span",{className:"hidden xl:inline",children:z.label})]},z.id)}),v&&m("button",{"data-testid":"stream-play-toggle","data-stream-playing":ve?"true":"false",onClick:ve?ke:he,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${ve?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:ve?"Stop stream":"Start stream",children:[ve?o(Yg,{className:"h-3 w-3"}):o($n,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:ve?"Stop":"Play"})]}),k&&m("button",{"data-testid":"stream-snapshot-refresh",onClick:k,disabled:x,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:[o(bl,{className:`h-3 w-3 ${x?"animate-spin":""}`}),o("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(T||M||u||Ne||g||X&&X.inputFps>0)&&m("div",{ref:G,className:"relative",children:[o("button",{onClick:()=>L(z=>!z),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:o(Jg,{className:"h-3.5 w-3.5"})}),_&&m("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:[w&&g&&m("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),m("span",{className:"tabular-nums text-foreground",children:[g.inputFps.toFixed(1)," fps"]})]}),m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Decode"}),m("span",{className:"tabular-nums text-foreground",children:[g.decodeFps.toFixed(1)," fps"]})]}),m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Uptime"}),o("span",{className:"tabular-nums text-foreground",children:Zg(g.uptimeMs)})]})]}),!w&&X&&X.inputFps>0&&m("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Input"}),m("span",{className:"tabular-nums text-foreground",children:[X.inputFps.toFixed(1)," fps"]})]}),X.bitrateKbps>0&&m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Bitrate"}),m("span",{className:"tabular-nums text-foreground",children:[X.bitrateKbps," kbps"]})]})]}),(u||T&&Ne)&&m("div",{className:"px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle",children:[m("div",{className:"flex justify-between gap-3 items-center",children:[o("span",{children:"Phase"}),m("span",{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${Ie?"text-red-400":"text-emerald-400"}`,children:[o("span",{className:`w-1.5 h-1.5 rounded-full ${Ie?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),Ie?"Active":"Watching"]})]}),u&&u.detectionFps>0&&m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Detection"}),m("span",{className:"tabular-nums text-foreground",children:[u.detectionFps.toFixed(1)," det/s"]})]}),u&&u.avgInferenceMs>0&&m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Inference"}),m("span",{className:"tabular-nums text-foreground",children:[u.avgInferenceMs.toFixed(0)," ms"]})]})]}),T&&m(we,{children:[o(un,{label:"Show detections",active:fe,onClick:()=>Z(z=>!z)}),o(un,{label:"Show motion",active:D,onClick:()=>F(z=>!z)})]}),M&&o(un,{label:"PTZ controls",active:P,onClick:()=>{V?.(),L(!1)}})]})]})]})]}),ve?o("div",{className:"aspect-video relative",children:o(Wg,{serverUrl:e,streamKey:B,autoPlay:!0,className:"w-full h-full",createSession:Oe,sendAnswer:r,closeSession:n,overlay:le||S||ge?m(we,{children:[le&&o(Fg,{detections:d,showPhaseIndicator:!1,showMotionZones:D,showMotionRaw:D,showDetections:fe}),S,ge&&A]}):void 0},B)}):o(tb,{src:y??null,isLoading:x,onPlay:he,onRetry:k,extraOverlay:S||ge?m(we,{children:[S,ge&&A]}):null,suppressPlayHover:!!S||ge}),N]})}function tb({src:e,isLoading:t,onPlay:r,onRetry:n,extraOverlay:s,suppressPlayHover:a=!1}){return e?m("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:[o("img",{src:e,alt:"Camera snapshot",className:"w-full h-full object-contain"}),!a&&o("button",{onClick:r,className:"absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 hover:opacity-100 transition-opacity cursor-pointer",children:o("div",{className:"h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center",children:o($n,{className:"h-7 w-7 text-white ml-0.5"})})}),s]}):t?o("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:o("div",{className:"h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin"})}):o("div",{className:"relative w-full aspect-video bg-black/90 flex items-center justify-center",children:m("div",{className:"flex flex-col items-center gap-2 text-white/40",children:[o(eb,{className:"h-8 w-8"}),o("span",{className:"text-xs",children:"No snapshot available"}),m("div",{className:"flex items-center gap-2 mt-1",children:[n&&m("button",{onClick:n,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:[o(bl,{className:"h-3 w-3"}),"Retry"]}),m("button",{onClick:r,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:[o($n,{className:"h-3 w-3"}),"Play Live"]})]})]})})}var xs={value:"auto",label:"Auto (best available)"};function rb(e){return e.charAt(0).toUpperCase()+e.slice(1)}function D5({deviceId:e,value:t,onChange:r,disabled:n,label:s,className:a}){const i=bt(),c=kh({deviceId:e},{refetchOnWindowFocus:!1}),[l,u]=E([xs]);Q(()=>{if(!c.data)return;const h=`${e}/`,g=[xs];for(const b of c.data){if(!b.enabled)continue;const v=b.brokerId.startsWith(h)?b.brokerId.slice(h.length):b.brokerId;g.push({value:v,label:rb(v)})}u(g)},[c.data,e]);const d=s??"Preferred stream",p=c.isLoading?"Loading available streams…":c.isError?"Could not load streams — only Auto available.":l.length===1?"No enabled streams found — only Auto available.":null;return m("div",{className:a,children:[o("label",{id:i,className:"text-xs font-medium text-foreground-muted block mb-1",children:d}),o(Ir,{"aria-labelledby":i,options:l,value:t,disabled:n,onChange:h=>r(h.target.value)}),p!==null&&o("p",{className:"text-foreground-subtle text-[10px] mt-1",children:p})]})}var nb=Object.defineProperty,Dr=Object.getOwnPropertySymbols,vl=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable,ws=(e,t,r)=>t in e?nb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bn=(e,t)=>{for(var r in t||(t={}))vl.call(t,r)&&ws(e,r,t[r]);if(Dr)for(var r of Dr(t))yl.call(t,r)&&ws(e,r,t[r]);return e},zn=(e,t)=>{var r={};for(var n in e)vl.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Dr)for(var n of Dr(e))t.indexOf(n)<0&&yl.call(e,n)&&(r[n]=e[n]);return r};/**
|
|
78
|
+
* @license QR Code generator library (TypeScript)
|
|
79
|
+
* Copyright (c) Project Nayuki.
|
|
80
|
+
* SPDX-License-Identifier: MIT
|
|
81
|
+
*/var vt;(e=>{const t=class ue{constructor(l,u,d,p){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<ue.MIN_VERSION||l>ue.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let h=[];for(let b=0;b<this.size;b++)h.push(!1);for(let b=0;b<this.size;b++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const g=this.addEccAndInterleave(d);if(this.drawCodewords(g),p==-1){let b=1e9;for(let v=0;v<8;v++){this.applyMask(v),this.drawFormatBits(v);const y=this.getPenaltyScore();y<b&&(p=v,b=y),this.applyMask(v)}}s(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(l,u){const d=e.QrSegment.makeSegments(l);return ue.encodeSegments(d,u)}static encodeBinary(l,u){const d=e.QrSegment.makeBytes(l);return ue.encodeSegments([d],u)}static encodeSegments(l,u,d=1,p=40,h=-1,g=!0){if(!(ue.MIN_VERSION<=d&&d<=p&&p<=ue.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let b,v;for(b=d;;b++){const w=ue.getNumDataCodewords(b,u)*8,N=i.getTotalBits(l,b);if(N<=w){v=N;break}if(b>=p)throw new RangeError("Data too long")}for(const w of[ue.Ecc.MEDIUM,ue.Ecc.QUARTILE,ue.Ecc.HIGH])g&&v<=ue.getNumDataCodewords(b,w)*8&&(u=w);let y=[];for(const w of l){r(w.mode.modeBits,4,y),r(w.numChars,w.mode.numCharCountBits(b),y);for(const N of w.getData())y.push(N)}s(y.length==v);const x=ue.getNumDataCodewords(b,u)*8;s(y.length<=x),r(0,Math.min(4,x-y.length),y),r(0,(8-y.length%8)%8,y),s(y.length%8==0);for(let w=236;y.length<x;w^=253)r(w,8,y);let k=[];for(;k.length*8<y.length;)k.push(0);return y.forEach((w,N)=>k[N>>>3]|=w<<7-(N&7)),new ue(b,u,k,h)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),u=l.length;for(let d=0;d<u;d++)for(let p=0;p<u;p++)d==0&&p==0||d==0&&p==u-1||d==u-1&&p==0||this.drawAlignmentPattern(l[d],l[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;let d=u;for(let h=0;h<10;h++)d=d<<1^(d>>>9)*1335;const p=(u<<10|d)^21522;s(p>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,n(p,h));this.setFunctionModule(8,7,n(p,6)),this.setFunctionModule(8,8,n(p,7)),this.setFunctionModule(7,8,n(p,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,n(p,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,n(p,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,n(p,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let d=0;d<12;d++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;s(u>>>18==0);for(let d=0;d<18;d++){const p=n(u,d),h=this.size-11+d%3,g=Math.floor(d/3);this.setFunctionModule(h,g,p),this.setFunctionModule(g,h,p)}}drawFinderPattern(l,u){for(let d=-4;d<=4;d++)for(let p=-4;p<=4;p++){const h=Math.max(Math.abs(p),Math.abs(d)),g=l+p,b=u+d;0<=g&&g<this.size&&0<=b&&b<this.size&&this.setFunctionModule(g,b,h!=2&&h!=4)}}drawAlignmentPattern(l,u){for(let d=-2;d<=2;d++)for(let p=-2;p<=2;p++)this.setFunctionModule(l+p,u+d,Math.max(Math.abs(p),Math.abs(d))!=1)}setFunctionModule(l,u,d){this.modules[u][l]=d,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,d=this.errorCorrectionLevel;if(l.length!=ue.getNumDataCodewords(u,d))throw new RangeError("Invalid argument");const p=ue.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u],h=ue.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u],g=Math.floor(ue.getNumRawDataModules(u)/8),b=p-g%p,v=Math.floor(g/p);let y=[];const x=ue.reedSolomonComputeDivisor(h);for(let w=0,N=0;w<p;w++){let S=l.slice(N,N+v-h+(w<b?0:1));N+=S.length;const M=ue.reedSolomonComputeRemainder(S,x);w<b&&S.push(0),y.push(S.concat(M))}let k=[];for(let w=0;w<y[0].length;w++)y.forEach((N,S)=>{(w!=v-h||S>=b)&&k.push(N[w])});return s(k.length==g),k}drawCodewords(l){if(l.length!=Math.floor(ue.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let p=0;p<this.size;p++)for(let h=0;h<2;h++){const g=d-h,b=(d+1&2)==0?this.size-1-p:p;!this.isFunction[b][g]&&u<l.length*8&&(this.modules[b][g]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let d=0;d<this.size;d++){let p;switch(l){case 0:p=(d+u)%2==0;break;case 1:p=u%2==0;break;case 2:p=d%3==0;break;case 3:p=(d+u)%3==0;break;case 4:p=(Math.floor(d/3)+Math.floor(u/2))%2==0;break;case 5:p=d*u%2+d*u%3==0;break;case 6:p=(d*u%2+d*u%3)%2==0;break;case 7:p=((d+u)%2+d*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][d]&&p&&(this.modules[u][d]=!this.modules[u][d])}}getPenaltyScore(){let l=0;for(let h=0;h<this.size;h++){let g=!1,b=0,v=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[h][y]==g?(b++,b==5?l+=ue.PENALTY_N1:b>5&&l++):(this.finderPenaltyAddHistory(b,v),g||(l+=this.finderPenaltyCountPatterns(v)*ue.PENALTY_N3),g=this.modules[h][y],b=1);l+=this.finderPenaltyTerminateAndCount(g,b,v)*ue.PENALTY_N3}for(let h=0;h<this.size;h++){let g=!1,b=0,v=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[y][h]==g?(b++,b==5?l+=ue.PENALTY_N1:b>5&&l++):(this.finderPenaltyAddHistory(b,v),g||(l+=this.finderPenaltyCountPatterns(v)*ue.PENALTY_N3),g=this.modules[y][h],b=1);l+=this.finderPenaltyTerminateAndCount(g,b,v)*ue.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let g=0;g<this.size-1;g++){const b=this.modules[h][g];b==this.modules[h][g+1]&&b==this.modules[h+1][g]&&b==this.modules[h+1][g+1]&&(l+=ue.PENALTY_N2)}let u=0;for(const h of this.modules)u=h.reduce((g,b)=>g+(b?1:0),u);const d=this.size*this.size,p=Math.ceil(Math.abs(u*20-d*10)/d)-1;return s(0<=p&&p<=9),l+=p*ue.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let d=[6];for(let p=this.size-7;d.length<l;p-=u)d.splice(1,0,p);return d}}static getNumRawDataModules(l){if(l<ue.MIN_VERSION||l>ue.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const d=Math.floor(l/7)+2;u-=(25*d-10)*d-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(ue.getNumRawDataModules(l)/8)-ue.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*ue.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let p=0;p<l-1;p++)u.push(0);u.push(1);let d=1;for(let p=0;p<l;p++){for(let h=0;h<u.length;h++)u[h]=ue.reedSolomonMultiply(u[h],d),h+1<u.length&&(u[h]^=u[h+1]);d=ue.reedSolomonMultiply(d,2)}return u}static reedSolomonComputeRemainder(l,u){let d=u.map(p=>0);for(const p of l){const h=p^d.shift();d.push(0),u.forEach((g,b)=>d[b]^=ue.reedSolomonMultiply(g,h))}return d}static reedSolomonMultiply(l,u){if(l>>>8||u>>>8)throw new RangeError("Byte out of range");let d=0;for(let p=7;p>=0;p--)d=d<<1^(d>>>7)*285,d^=(u>>>p&1)*l;return s(d>>>8==0),d}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const d=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(d&&l[0]>=u*4&&l[6]>=u?1:0)+(d&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,d){return l&&(this.finderPenaltyAddHistory(u,d),u=0),u+=this.size,this.finderPenaltyAddHistory(u,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function r(c,l,u){if(l<0||l>31||c>>>l)throw new RangeError("Value out of range");for(let d=l-1;d>=0;d--)u.push(c>>>d&1)}function n(c,l){return(c>>>l&1)!=0}function s(c){if(!c)throw new Error("Assertion error")}const a=class Se{constructor(l,u,d){if(this.mode=l,this.numChars=u,this.bitData=d,u<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(l){let u=[];for(const d of l)r(d,8,u);return new Se(Se.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!Se.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let d=0;d<l.length;){const p=Math.min(l.length-d,3);r(parseInt(l.substring(d,d+p),10),p*3+1,u),d+=p}return new Se(Se.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!Se.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],d;for(d=0;d+2<=l.length;d+=2){let p=Se.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d))*45;p+=Se.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d+1)),r(p,11,u)}return d<l.length&&r(Se.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d)),6,u),new Se(Se.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:Se.isNumeric(l)?[Se.makeNumeric(l)]:Se.isAlphanumeric(l)?[Se.makeAlphanumeric(l)]:[Se.makeBytes(Se.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)r(l,8,u);else if(l<16384)r(2,2,u),r(l,14,u);else if(l<1e6)r(6,3,u),r(l,21,u);else throw new RangeError("ECI assignment value out of range");return new Se(Se.Mode.ECI,0,u)}static isNumeric(l){return Se.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Se.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let d=0;for(const p of l){const h=p.mode.numCharCountBits(u);if(p.numChars>=1<<h)return 1/0;d+=4+h+p.bitData.length}return d}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let d=0;d<l.length;d++)l.charAt(d)!="%"?u.push(l.charCodeAt(d)):(u.push(parseInt(l.substring(d+1,d+3),16)),d+=2);return u}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let i=a;e.QrSegment=a})(vt||(vt={}));(e=>{(t=>{const r=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(vt||(vt={}));(e=>{(t=>{const r=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(vt||(vt={}));var Pt=vt;/**
|
|
82
|
+
* @license qrcode.react
|
|
83
|
+
* Copyright (c) Paul O'Shannessy
|
|
84
|
+
* SPDX-License-Identifier: ISC
|
|
85
|
+
*/var ob={L:Pt.QrCode.Ecc.LOW,M:Pt.QrCode.Ecc.MEDIUM,Q:Pt.QrCode.Ecc.QUARTILE,H:Pt.QrCode.Ecc.HIGH},xl=128,wl="L",kl="#FFFFFF",Nl="#000000",Sl=!1,Cl=1,sb=4,ab=0,ib=.1;function Ml(e,t=0){const r=[];return e.forEach(function(n,s){let a=null;n.forEach(function(i,c){if(!i&&a!==null){r.push(`M${a+t} ${s+t}h${c-a}v1H${a+t}z`),a=null;return}if(c===n.length-1){if(!i)return;a===null?r.push(`M${c+t},${s+t} h1v1H${c+t}z`):r.push(`M${a+t},${s+t} h${c+1-a}v1H${a+t}z`);return}i&&a===null&&(a=c)})}),r.join("")}function El(e,t){return e.slice().map((r,n)=>n<t.y||n>=t.y+t.h?r:r.map((s,a)=>a<t.x||a>=t.x+t.w?s:!1))}function lb(e,t,r,n){if(n==null)return null;const s=e.length+r*2,a=Math.floor(t*ib),i=s/t,c=(n.width||a)*i,l=(n.height||a)*i,u=n.x==null?e.length/2-c/2:n.x*i,d=n.y==null?e.length/2-l/2:n.y*i,p=n.opacity==null?1:n.opacity;let h=null;if(n.excavate){let b=Math.floor(u),v=Math.floor(d);h={x:b,y:v,w:Math.ceil(c+u-b),h:Math.ceil(l+d-v)}}const g=n.crossOrigin;return{x:u,y:d,h:l,w:c,excavation:h,opacity:p,crossOrigin:g}}function cb(e,t){return t!=null?Math.max(Math.floor(t),0):e?sb:ab}function Al({value:e,level:t,minVersion:r,includeMargin:n,marginSize:s,imageSettings:a,size:i,boostLevel:c}){let l=Me.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((b,v)=>(b.push(...Pt.QrSegment.makeSegments(v)),b),[]);return Pt.QrCode.encodeSegments(g,ob[t],r,void 0,void 0,c)},[e,t,r,c]);const{cells:u,margin:d,numCells:p,calculatedImageSettings:h}=Me.useMemo(()=>{let g=l.getModules();const b=cb(n,s);return{cells:g,margin:b,numCells:g.length+b*2,calculatedImageSettings:lb(g,i,b,a)}},[l,i,a,n,s]);return{qrcode:l,margin:d,cells:u,numCells:p,calculatedImageSettings:h}}var ub=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),db=Me.forwardRef(function(t,r){const n=t,{value:s,size:a=xl,level:i=wl,bgColor:c=kl,fgColor:l=Nl,includeMargin:u=Sl,minVersion:d=Cl,boostLevel:p,marginSize:h,imageSettings:g}=n,b=zn(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=b,y=zn(b,["style"]),x=g?.src,k=Me.useRef(null),w=Me.useRef(null),N=Me.useCallback(ne=>{k.current=ne,typeof r=="function"?r(ne):r&&(r.current=ne)},[r]),[S,M]=Me.useState(!1),{margin:P,cells:A,numCells:V,calculatedImageSettings:H}=Al({value:s,level:i,minVersion:d,boostLevel:p,includeMargin:u,marginSize:h,imageSettings:g,size:a});Me.useEffect(()=>{if(k.current!=null){const ne=k.current,se=ne.getContext("2d");if(!se)return;let oe=A;const J=w.current,K=H!=null&&J!==null&&J.complete&&J.naturalHeight!==0&&J.naturalWidth!==0;K&&H.excavation!=null&&(oe=El(A,H.excavation));const fe=window.devicePixelRatio||1;ne.height=ne.width=a*fe;const Z=a/V*fe;se.scale(Z,Z),se.fillStyle=c,se.fillRect(0,0,V,V),se.fillStyle=l,ub?se.fill(new Path2D(Ml(oe,P))):A.forEach(function(D,F){D.forEach(function(O,ie){O&&se.fillRect(ie+P,F+P,1,1)})}),H&&(se.globalAlpha=H.opacity),K&&se.drawImage(J,H.x+P,H.y+P,H.w,H.h)}}),Me.useEffect(()=>{M(!1)},[x]);const ae=Bn({height:a,width:a},v);let pe=null;return x!=null&&(pe=Me.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{M(!0)},ref:w,crossOrigin:H?.crossOrigin})),Me.createElement(Me.Fragment,null,Me.createElement("canvas",Bn({style:ae,height:a,width:a,ref:N,role:"img"},y)),pe)});db.displayName="QRCodeCanvas";var Pl=Me.forwardRef(function(t,r){const n=t,{value:s,size:a=xl,level:i=wl,bgColor:c=kl,fgColor:l=Nl,includeMargin:u=Sl,minVersion:d=Cl,boostLevel:p,title:h,marginSize:g,imageSettings:b}=n,v=zn(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:y,cells:x,numCells:k,calculatedImageSettings:w}=Al({value:s,level:i,minVersion:d,boostLevel:p,includeMargin:u,marginSize:g,imageSettings:b,size:a});let N=x,S=null;b!=null&&w!=null&&(w.excavation!=null&&(N=El(x,w.excavation)),S=Me.createElement("image",{href:b.src,height:w.h,width:w.w,x:w.x+y,y:w.y+y,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const M=Ml(N,y);return Me.createElement("svg",Bn({height:a,width:a,viewBox:`0 0 ${k} ${k}`,ref:r,role:"img"},v),!!h&&Me.createElement("title",null,h),Me.createElement("path",{fill:c,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),Me.createElement("path",{fill:l,d:M,shapeRendering:"crispEdges"}),S)});Pl.displayName="QRCodeSVG";var pb=192;function fb({value:e,size:t=pb,className:r,alt:n}){const s=e.trim();return s.length===0?null:o("div",{className:C("inline-flex rounded-md bg-white p-2",r),children:o(Pl,{value:s,size:t,marginSize:1,title:n??"QR code"})})}var mb=2e3;function hb({value:e,label:t,className:r,disabled:n}){const[s,a]=E(!1),i=R(()=>{e&&navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),mb)})},[e]);return m(at,{size:"sm",variant:"ghost",type:"button",disabled:n||e.length===0,onClick:i,className:C(r),"aria-label":s?"Copied":`Copy ${t??"value"}`,children:[s?o(sr,{className:"h-3.5 w-3.5 text-success"}):o(dt,{className:"h-3.5 w-3.5"}),t?o("span",{className:"ml-1",children:s?"Copied":t}):null]})}var gb=Xl(Zl),ks=1e4;function Ns(e){return e==="linked"?"success":e==="error"?"danger":"warning"}function Ss(e){return e==="linked"?"Linked":e==="unlinked"?"Unlinked":e==="error"?"Error":e}function bb({field:e}){const[t,r]=E(!1),n=e.secret===!0,s=n&&!t?"•".repeat(Math.min(e.value.length,24)):e.value;return m("div",{className:"flex items-center gap-2 py-1.5",children:[o("span",{className:"text-[11px] text-foreground-subtle w-32 shrink-0",children:e.label}),o("span",{className:"flex-1 min-w-0 truncate font-mono text-xs text-foreground",children:s||"—"}),n&&o(at,{size:"sm",variant:"ghost",type:"button","aria-label":t?"Hide value":"Reveal value",onClick:()=>r(a=>!a),children:t?o(to,{className:"h-3.5 w-3.5"}):o(Bt,{className:"h-3.5 w-3.5"})}),o(hb,{value:e.value,label:e.label})]})}function vb({setup:e}){const t=e.fields??[];return m("div",{className:"border-b border-border bg-surface-hover/10",children:[m("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border",children:[o(xp,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Setup"})]}),m("div",{className:"flex flex-col gap-3 p-4 sm:flex-row sm:items-start",children:[e.qr&&o("div",{className:"shrink-0",children:o(fb,{value:e.qr,alt:"Pairing QR code"})}),m("div",{className:"flex-1 min-w-0",children:[e.note&&o("p",{className:"text-xs text-foreground-muted whitespace-pre-line mb-2",children:e.note}),t.length>0&&o("div",{className:"divide-y divide-border-subtle",children:t.map(r=>o(bb,{field:r},r.label))})]})]})]})}function $5({addonId:e,onOpenDevice:t}){const r=or(),n=Nh({nodeId:"hub",addonId:e},{refetchInterval:ks,retry:!1}),s=Sh({nodeId:"hub",addonId:e},{refetchInterval:ks,retry:!1}),a=Ch({onSuccess:()=>{r.invalidateQueries({queryKey:[["deviceExport"]]})}}),i=q(()=>{const g=Wl.safeParse(n.data);return g.success?g.data:null},[n.data]),c=q(()=>{const g=gb.safeParse(s.data);return g.success?g.data:[]},[s.data]),l=i?.linkState??"unlinked",u=q(()=>c.map(g=>({deviceId:g.deviceId,displayName:g.exposedAs??`Device ${g.deviceId}`,streamPreference:"auto",linkState:l})),[c,l]),d=n.isLoading||s.isLoading,p=i?.exposedDeviceCount??u.length,h=q(()=>[{key:"device",header:"Device",render:g=>m("div",{className:"flex flex-col",children:[o("span",{className:"text-foreground font-medium",children:g.displayName}),m("span",{className:"text-foreground-subtle text-xs font-mono",children:["#",g.deviceId]})]})},{key:"status",header:"Status",render:g=>o(gt,{variant:Ns(g.linkState),children:Ss(g.linkState)})},{key:"stream",header:"Stream",render:g=>o("span",{className:"text-xs text-foreground-subtle font-mono",children:g.streamPreference==="auto"?"Auto":g.streamPreference})},{key:"actions",header:"",align:"right",render:g=>m("div",{className:"flex items-center justify-end gap-2",children:[t&&m(at,{size:"sm",variant:"ghost",onClick:()=>t(g.deviceId),children:[o(eo,{className:"h-3.5 w-3.5 mr-1"}),"Open"]}),m(at,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>a.mutate({deviceId:g.deviceId,nodeId:"hub",addonId:e}),children:[o(Lp,{className:"h-3.5 w-3.5 mr-1"}),"Unexpose"]})]})}],[t,a,e]);return m("div",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[m("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-b border-border bg-surface-hover/20",children:[m("div",{className:"flex items-center gap-2 min-w-0",children:[o(Bo,{className:"h-3.5 w-3.5 text-foreground-subtle shrink-0"}),o("span",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide",children:"Exported devices"}),o(gt,{variant:Ns(l),children:Ss(l)}),m("span",{className:"text-[11px] text-foreground-subtle",children:[p," exposed"]})]}),d&&o(Fe,{className:"h-3.5 w-3.5 animate-spin text-foreground-subtle"})]}),i?.error&&o("div",{className:"px-4 py-3 border-b border-border",children:o(Mf,{message:i.error})}),i?.setup&&o(vb,{setup:i.setup}),u.length===0?o(Sf,{icon:Bo,title:"No devices exposed",description:`Expose a camera to "${e}" from its device-details page to surface it in the connected ecosystem.`}):o("div",{className:"p-3",children:o(of,{columns:h,rows:u,rowKey:g=>g.deviceId})})]})}function B5({samples:e,sampleRate:t=16e3,height:r=96,className:n="",color:s="#3b82f6",bgColor:a="transparent"}){const i=W(null),c=W(null),l=R(()=>{const d=i.current,p=c.current;if(!d||!p||!e||e.length===0)return;const h=p.clientWidth;if(h===0)return;const g=window.devicePixelRatio||1;d.width=h*g,d.height=r*g,d.style.width=`${h}px`,d.style.height=`${r}px`;const b=d.getContext("2d");if(!b)return;b.scale(g,g),a!=="transparent"?(b.fillStyle=a,b.fillRect(0,0,h,r)):b.clearRect(0,0,h,r);const v=e.length/h,y=r/2;b.fillStyle=s,b.globalAlpha=.7;for(let x=0;x<h;x++){const k=Math.floor(x*v),w=Math.min(Math.floor((x+1)*v),e.length);let N=0,S=0;for(let V=k;V<w;V++){const H=e[V];H<N&&(N=H),H>S&&(S=H)}const M=y-S*y,P=y-N*y,A=Math.max(1,P-M);b.fillRect(x,M,1,A)}b.globalAlpha=1,b.strokeStyle=s,b.globalAlpha=.2,b.lineWidth=1,b.beginPath(),b.moveTo(0,y),b.lineTo(h,y),b.stroke(),b.globalAlpha=1},[e,r,s,a]);Q(()=>{l()},[l]),Q(()=>{const d=new ResizeObserver(()=>l()),p=c.current;return p&&d.observe(p),()=>d.disconnect()},[l]);const u=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return m("div",{ref:c,className:`relative ${n}`,children:[o("canvas",{ref:i,className:"w-full rounded-md"}),e&&e.length>0&&m("div",{className:"absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono",children:[u,"s · ",t/1e3,"kHz · ",e.length.toLocaleString()," samples"]})]})}function z5({currentDbfs:e,durationSec:t=30,maxSamples:r=120,height:n=64,className:s="",color:a="#10b981",clipColor:i="#ef4444",clipThreshold:c=-6,minDbfs:l=-96}){const u=W(null),d=W(null),[p,h]=E([]);Q(()=>{e!==null&&h(v=>{const y=[...v,{dbfs:e,timestamp:Date.now()}];return y.length>r?y.slice(-r):y})},[e,r]);const g=R(()=>{const v=u.current,y=d.current;if(!v||!y)return;const x=y.clientWidth;if(x===0)return;const k=window.devicePixelRatio||1;v.width=x*k,v.height=n*k,v.style.width=`${x}px`,v.style.height=`${n}px`;const w=v.getContext("2d");if(!w||(w.scale(k,k),w.clearRect(0,0,x,n),p.length===0))return;const N=p[p.length-1].timestamp,S=t*1e3,M=N-S,P=p.filter(ae=>ae.timestamp>=M);if(P.length===0)return;const A=Math.max(1,Math.floor(x/(t*2))),V=Math.abs(l);for(const ae of P){const pe=ae.timestamp-M,ne=Math.floor(pe/S*x),se=(Math.max(l,Math.min(0,ae.dbfs))-l)/V,oe=Math.max(1,se*n);w.fillStyle=ae.dbfs>=c?i:a,w.globalAlpha=.8,w.fillRect(ne,n-oe,A,oe)}w.globalAlpha=1;const H=n-(c-l)/V*n;w.strokeStyle=i,w.globalAlpha=.25,w.lineWidth=1,w.setLineDash([4,4]),w.beginPath(),w.moveTo(0,H),w.lineTo(x,H),w.stroke(),w.setLineDash([]),w.globalAlpha=1},[p,t,n,a,i,c,l]);Q(()=>{g()},[g]),Q(()=>{const v=new ResizeObserver(()=>g()),y=d.current;return y&&v.observe(y),()=>v.disconnect()},[g]);const b=p.length>0?p[p.length-1].dbfs:null;return m("div",{ref:d,className:`relative ${s}`,children:[o("canvas",{ref:u,className:"w-full rounded-md"}),m("div",{className:"absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono",children:[t,"s"]}),b!==null&&m("div",{className:"absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono",children:[b.toFixed(1)," dBFS · ",p.length," samples"]})]})}function yb(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function xb(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function F5({classifications:e,processing:t=!1,inferenceMs:r,maxItems:n=10,className:s=""}){const a=e.slice(0,n),i=a.length>0?a[0].score:1;return t?o("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:o("div",{className:"text-sm text-foreground-subtle animate-pulse",children:"Classifying audio..."})}):a.length===0?o("div",{className:`rounded-xl border border-border bg-surface p-4 text-center ${s}`,children:o("div",{className:"text-xs text-foreground-subtle",children:"No classifications yet"})}):m("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${s}`,children:[m("div",{className:"px-3 py-2 border-b border-border flex items-center justify-between",children:[o("h3",{className:"text-xs font-medium text-foreground",children:"Audio Classifications"}),m("div",{className:"flex items-center gap-3 text-[10px] text-foreground-subtle",children:[a.length<e.length&&m("span",{children:["showing ",a.length," of ",e.length]}),r!==void 0&&m("span",{className:"font-mono",children:[r.toFixed(1),"ms"]})]})]}),o("div",{className:"divide-y divide-border/50",children:a.map((c,l)=>{const u=i>0?c.score/i*100:0;return m("div",{className:"px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30",children:[o("span",{className:"text-[10px] text-foreground-subtle w-5 text-right font-mono",children:l+1}),o("span",{className:"text-xs font-medium text-foreground min-w-[120px]",children:c.className}),o("div",{className:"flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden",children:o("div",{className:`h-full rounded-full transition-all duration-300 ${yb(c.score)}`,style:{width:`${u}%`}})}),m("span",{className:`text-xs font-mono font-semibold w-14 text-right ${xb(c.score)}`,children:[(c.score*100).toFixed(1),"%"]})]},`${c.className}-${l}`)})})]})}function G5({data:e,label:t="Response",className:r=""}){const[n,s]=E(!1);if(!e)return null;const a=JSON.stringify(e,null,2);return m("div",{className:`rounded-xl border border-border bg-surface overflow-hidden ${r}`,children:[m("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:()=>s(i=>!i),children:[m("div",{className:"flex items-center gap-2",children:[o("span",{className:"text-[10px] text-foreground-subtle",children:n?"▼":"▶"}),o("h3",{className:"text-xs font-medium text-foreground",children:t})]}),o("span",{className:"text-[10px] text-foreground-subtle font-mono",children:a.length>1e3?`${(a.length/1024).toFixed(1)} KB`:`${a.length} bytes`})]}),n&&o("div",{className:"max-h-80 overflow-y-auto overflow-x-auto",children:o("pre",{className:"p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre",children:a})})]})}var wb={Activity:ot,Eye:Bt,AlertTriangle:Ft,PauseCircle:np,PowerOff:yp};function Q5({phase:e,...t}){const r=wb[ua(e).icon];return o(r,{...t})}function Wt(e){const[t,r]=E([]),n=R(a=>{r(i=>{const c=[...i,a];return c.length>e?c.slice(-e):c})},[e]),s=R(()=>{r([])},[]);return q(()=>({entries:t,append:n,reset:s}),[t,n,s])}function Cs(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 Ms={error:{icon:$t,color:"text-red-400"},warn:{icon:Ft,color:"text-amber-400"},info:{icon:pp,color:"text-blue-400"},debug:{icon:Yd,color:"text-gray-500"}},Es={debug:0,info:1,warn:2,error:3},kb=["all","debug","info","warn","error"],Nb=500;function Sb(e,t){return t?(Es[e]??0)>=(Es[t]??0):!0}function Rl({agentId:e,addonId:t,deviceId:r,integrationId:n,requestId:s,level:a,maxHeight:i="max-h-96",showScope:c=!1,showFilters:l=!0,limit:u=100,liveBuffer:d,onClose:p,className:h}){const[g,b]=E(""),[v,y]=E(""),[x,k]=E(a),w=e,N=t??(g||void 0),S=r??(v?Number(v):void 0),M=n,P=s,A=q(()=>{const T={};return w&&(T.agentId=w),N&&(T.addonId=N),S!==void 0&&Number.isFinite(S)&&(T.deviceId=S),M&&(T.integrationId=M),P&&(T.requestId=P),Object.keys(T).length>0?T:void 0},[w,N,S,M,P]),V=Wt(Nb),H=d??V,ae=H.entries,[pe,ne]=E(0),[se,oe]=E(!1),[J,K]=E(!1),[fe,Z]=E(new Set),[D,F]=E(""),O=W(null),ie=`${w??""}:${N??""}:${String(S??"")}:${M??""}:${P??""}`,_=W(ie);Q(()=>{_.current!==ie&&(_.current=ie,H.reset(),ne(0),Z(new Set))},[ie,H]);const{data:L,isLoading:G}=f.logs.query.useQuery({...A?{tags:A}:{},limit:u},{staleTime:3e4});f.logs.subscribe.useSubscription({...A?{tags:A}:{}},{onData:T=>{H.append(T)}});const B=W(ae.length);Q(()=>{const T=O.current;if(!T){B.current=ae.length;return}const le=B.current;if(B.current=ae.length,!(ae.length<=le)){if(se&&T.scrollTop<=8)T.scrollTo({top:0});else if(!se&&T.scrollTop>0){const ge=T.querySelector("tbody tr"),ve=ge instanceof HTMLElement?ge.offsetHeight:24;T.scrollTop+=ve*(ae.length-le)}}},[ae.length,se]);const te=q(()=>{const T=(L??[]).map(re=>({timestamp:re.timestamp,level:re.level,message:re.message,scope:re.scope,tags:re.tags,meta:re.meta})),le=new Set,ge=[];for(const re of[...ae].reverse()){const xe=`${re.timestamp}|${re.level}|${re.scope??""}|${re.message}`;le.has(xe)||(le.add(xe),ge.push(re))}for(const re of T){const xe=`${re.timestamp}|${re.level}|${re.scope??""}|${re.message}`;le.has(xe)||(le.add(xe),ge.push(re))}const ve=(pe>0?ge.filter(re=>new Date(re.timestamp).getTime()>pe):ge).filter(re=>Sb(re.level,x)),z=D.trim().toLowerCase();return z?ve.filter(re=>{if(re.message.toLowerCase().includes(z)||re.scope&&re.scope.toLowerCase().includes(z))return!0;if(re.tags){for(const xe of Object.values(re.tags))if(xe!==void 0&&String(xe).toLowerCase().includes(z))return!0}if(re.meta){for(const xe of Object.values(re.meta))if(xe!=null&&Cs(xe).toLowerCase().includes(z))return!0}return!1}):ve},[L,ae,x,pe,D]),X=R(()=>{const T=te.map(le=>{const ge=new Date(le.timestamp).toLocaleTimeString(),ve=le.tags?" "+Object.entries(le.tags).filter(([,z])=>z).map(([z,re])=>`${z}=${re}`).join(" "):"";return`${ge} [${le.level.toUpperCase()}]${le.scope?` [${le.scope}]`:""}${ve} ${le.message}`});navigator.clipboard.writeText(T.join(`
|
|
86
|
+
`)).then(()=>{K(!0),setTimeout(()=>K(!1),1500)})},[te]),Le=f.logs.clear.useMutation(),Oe=R(()=>{ne(Date.now()),H.reset(),Le.mutate({...A?{tags:A}:{}})},[H,Le,A]),ee=R(T=>{Z(le=>{const ge=new Set(le);return ge.has(T)?ge.delete(T):ge.add(T),ge})},[]),[he,ke]=E(null),Ne=R((T,le)=>{const ge=new Date(T.timestamp).toISOString(),ve=T.tags?" "+Object.entries(T.tags).filter(([,xe])=>xe).map(([xe,Ye])=>`${xe}=${Ye}`).join(" "):"",z=T.meta&&Object.keys(T.meta).length>0?` meta=${JSON.stringify(T.meta)}`:"",re=`${ge} [${T.level.toUpperCase()}]${T.scope?` [${T.scope}]`:""}${ve} ${T.message}${z}`;navigator.clipboard.writeText(re).then(()=>{ke(le),setTimeout(()=>ke(xe=>xe===le?null:xe),1200)})},[]),Ie=R(T=>`${T.timestamp}|${T.level}|${T.scope??""}|${T.message}`,[]);return m("div",{className:C("h-full min-h-0 flex flex-col",h),onClick:T=>T.stopPropagation(),children:[m("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Logs"}),w&&o(dn,{label:"agent",value:w}),N&&o(dn,{label:"addon",value:N}),S!==void 0&&o(dn,{label:"device",value:`#${S}`}),o("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:kb.map(T=>m("button",{type:"button",onClick:()=>k(T==="all"?void 0:T),className:C("px-1.5 py-0.5 capitalize transition-colors",T==="all"&&!x||x===T?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",T!=="all"&&"border-l border-border"),children:[T,T!=="all"?"+":""]},T))}),o(pn,{icon:Ya,label:se?"Auto":"Paused",active:!se,onClick:()=>{oe(T=>!T),!se&&O.current&&O.current.scrollTo({top:0,behavior:"smooth"})}}),o(pn,{icon:dt,label:J?"Copied!":"Copy",onClick:X,disabled:te.length===0}),o(pn,{icon:et,label:"Clear",onClick:Oe}),m("div",{className:"relative",children:[o("input",{type:"text",value:D,onChange:T=>F(T.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"}),D&&o("button",{type:"button",onClick:()=>F(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(_e,{className:"h-2.5 w-2.5"})})]}),ae.length>0&&m("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",ae.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(_e,{className:"h-3.5 w-3.5"})})]}),l&&(!t||!r)&&m("div",{className:"flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]",children:[!t&&m("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Addon:"}),o("input",{type:"text",value:g,onChange:T=>b(T.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"})]}),!r&&m("label",{className:"flex items-center gap-1",children:[o("span",{className:"text-foreground-subtle",children:"Device:"}),o("input",{type:"text",inputMode:"numeric",value:v,onChange:T=>y(T.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"})]})]}),m("div",{ref:O,className:C("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[G&&m("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Fe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading logs..."]}),!G&&te.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No logs found"}),te.length>0&&o("table",{className:"w-full",children:o("tbody",{children:te.map(T=>{const le=Ms[T.level]??Ms.info,ge=le.icon,ve=Ie(T),z=fe.has(ve),re=T.tags&&Object.keys(T.tags).length>0,xe=T.meta&&Object.keys(T.meta).length>0,Ye=re||xe;return m("tr",{className:C("hover:bg-surface-hover/30 border-b border-border/30",Ye&&"cursor-pointer"),onClick:Ye?()=>ee(ve):void 0,children:[o("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(T.timestamp).toLocaleTimeString()}),o("td",{className:C("px-1 py-1 align-top w-5",le.color),children:o(ge,{className:"h-3 w-3"})}),c&&o("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:T.scope,children:T.scope?.replace(/^addon:/,"")??""}),o("td",{className:"px-2 py-1 text-foreground break-all",children:m("div",{className:"flex items-start gap-1",children:[Ye&&(z?o(xt,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):o(ut,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),m("div",{className:"flex-1 min-w-0",children:[T.message,z&&Ye&&m("div",{className:"mt-1 text-[9px] text-foreground-subtle bg-surface rounded px-2 py-1 space-y-0.5",children:[xe&&Object.entries(T.meta).filter(([,$e])=>$e!==void 0&&$e!=="").map(([$e,Nt])=>m("div",{children:[o("span",{className:"text-amber-400/80 font-medium",children:$e}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:Cs(Nt)})]},`m-${$e}`)),re&&Object.entries(T.tags).filter(([,$e])=>$e!==void 0).map(([$e,Nt])=>m("div",{children:[o("span",{className:"text-primary/70 font-medium",children:$e}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:Nt})]},`t-${$e}`))]})]})]})}),o("td",{className:"px-1 py-1 align-top w-5",children:o(Cb,{copied:he===ve,onCopy:()=>Ne(T,ve)})})]},ve)})})})]})]})}function j5({position:e="bottom",className:t,...r}){return o("div",{className:C(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",t),children:o(Rl,{maxHeight:"max-h-48",...r})})}function dn({label:e,value:t}){return m("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function Cb({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this row",onClick:r=>{r.stopPropagation(),t()},className:C("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?o(sr,{className:"h-3 w-3"}):o(dt,{className:"h-3 w-3"})})}function pn({icon:e,label:t,onClick:r,disabled:n,active:s}){return m("button",{type:"button",onClick:r,disabled:n,className:C("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",s?"border-amber-500/30 bg-amber-500/10 text-amber-400":"border-border text-foreground-subtle hover:text-foreground",n&&"opacity-40 cursor-not-allowed"),children:[o(e,{className:"h-2.5 w-2.5"}),t]})}function Mb(e,t,r,n){if(n!==void 0&&(e.source.deviceId??(e.source.type==="device"&&typeof e.source.id=="number"?e.source.id:void 0))!==n||r!==void 0&&(e.source.addonId??(e.source.type==="addon"&&typeof e.source.id=="string"?e.source.id:void 0))!==r)return!1;if(t!==void 0){const s=e.source.nodeId;if(!s||s!==t&&!s.startsWith(`${t}/`))return!1}return!0}var Eb={[Y.AddonStarted]:{icon:Cn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[Y.AddonInstalled]:{icon:Nn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[Y.AddonRestarted]:{icon:Br,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[Y.AddonUpdated]:{icon:di,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[Y.AddonStopped]:{icon:zo,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[Y.AddonUninstalled]:{icon:et,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[Y.AddonCrashed]:{icon:$t,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[Y.AddonError]:{icon:Ft,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[Y.DetectionPhaseTransition]:{icon:ot,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[Y.DetectionResult]:{icon:Np,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[Y.DetectionEvent]:{icon:Bt,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[Y.DetectionCameraNative]:{icon:Fo,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[Y.ProviderMotion]:{icon:Go,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Y.MotionOnMotionChanged]:{icon:Go,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[Y.MotionAnalysis]:{icon:ot,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[Y.MotionZonesRaw]:{icon:ot,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[Y.ProviderDetection]:{icon:Fo,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[Y.PipelineAudioInferenceResult]:{icon:si,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[Y.AgentOnline]:{icon:Cn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[Y.AgentOffline]:{icon:zo,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[Y.DeviceRegistered]:{icon:Nn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[Y.DeviceUnregistered]:{icon:et,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[Y.DeviceStateChanged]:{icon:ot,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function Fn(e,t){const r=Eb[e]??{icon:Cn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===Y.DeviceStateChanged&&t&&typeof t.capName=="string"){const n=t.capName;return{...r,label:n}}return r}var Mt=Object.freeze([...new Set(Object.values(Y))].sort()),Ab=Object.freeze([Y.PipelineCameraMetricsSnapshot,Y.PipelineRunnerLoadSnapshot,Y.PipelineEngineMetricsSnapshot,Y.PipelineInferenceResult,Y.PipelineTrace,Y.PipelineProgress,Y.StreamBrokerMetricsSnapshot,Y.MetricsNodeResourcesSnapshot,Y.MetricsNodeProcessesSnapshot,Y.ClusterTopologySnapshot,Y.MotionAnalysis,Y.MotionZonesRaw,Y.DetectionResult,Y.PipelineAudioInferenceResult,Y.PlatformProbePhase,Y.BenchmarkProgress,Y.ModelDownloadProgress]),Pb=new Set(Ab),Rb=Object.freeze(Mt.filter(e=>!Pb.has(e)));function Er(e,t){if(e===Y.DetectionPhaseTransition){const s=t.to,a=t.from,i=typeof t.source=="string"?t.source:null,c=typeof t.cooldownMs=="number"?t.cooldownMs:null,l=i?` (${i}${c?`, ${Math.round(c/1e3)}s cooldown`:""})`:"";return s==="active"?`Motion detected — phase active${l}`:s==="watching"?`Cooldown expired — phase watching${l}`:`Phase: ${String(a)} → ${String(s)}${l}`}if(e===Y.DetectionResult){const s=t.frame?.detections??[];if(s.length===0)return null;const a=new Map;for(const i of s){const c=i,l=c.class??c.macroClass,u=typeof l=="string"?l:"";u&&a.set(u,(a.get(u)??0)+1)}return[...a.entries()].map(([i,c])=>c>1?`${i} ×${c}`:i).join(", ")}if(e===Y.PipelineAudioInferenceResult){const s=t.frame?.detections??[];return s.length===0?null:s.map(a=>{const i=a,c=i.macroClass??i.class??i.label,l=typeof c=="string"?c:"",u=i.score;return u?`${l} (${Math.round(u*100)}%)`:l}).filter(Boolean).join(", ")}if(e===Y.DetectionEvent){const s=t.label??t.class,a=t.score??t.confidence,i=[];return typeof s=="string"&&i.push(s),typeof a=="number"&&i.push(`${Math.round(a*100)}%`),i.length>0?i.join(" — "):null}if(e===Y.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===Y.DeviceStateChanged){const s=t.slice;if(s&&typeof s=="object"){const a=Object.keys(s).filter(i=>i!=="lastFetchedAt"&&i!=="ts");if(a.length>0)return a.slice(0,4).join(", ")+(a.length>4?"…":"")}return null}if(e===Y.MotionOnMotionChanged){const s=t.detected,a=typeof t.source=="string"?t.source:null,i=s===!0?"motion start":s===!1?"motion stop":"motion";return a?`${i} (${a})`:i}if(e===Y.ProviderDetection||e===Y.DetectionCameraNative){const s=t.detections??[];if(!Array.isArray(s)||s.length===0)return(typeof t.class=="string"?t.class:null)??null;const a=new Map;for(const i of s){const c=i,l=c.class??c.macroClass,u=typeof l=="string"?l:"";u&&a.set(u,(a.get(u)??0)+1)}return[...a.entries()].map(([i,c])=>c>1?`${i} ×${c}`:i).join(", ")}const r=t.addonId,n=t.error;return n||(r?`addon: ${r}`:null)}function _b(e){const t=e.category;return t===Y.DetectionResult||t===Y.PipelineAudioInferenceResult?Er(t,e.data)!==null:!0}var Ib=300;function _l({agentId:e,addonId:t,deviceId:r,defaultCategories:n,categories:s,category:a,maxHeight:i="max-h-96",limit:c=50,showCategoryFilter:l=!0,showFilters:u=!1,liveBuffer:d,onClose:p,className:h}){const g=q(()=>n??s??Rb,[n,s]),b=q(()=>[...g].sort().join(","),[g]),[v,y]=E(()=>new Set(g)),x=W(b);Q(()=>{x.current!==b&&(x.current=b,y(new Set(g)))},[b,g]);const k=Wt(Ib),w=d??k,N=w.entries,[S,M]=E(!0),[P,A]=E(new Set),[V,H]=E(""),[ae,pe]=E(!1),[ne,se]=E(""),[oe,J]=E(0),K=W(null),fe=W(null),Z=`${e??""}:${t??""}:${String(r??"")}:${a??""}`,D=W(Z);Q(()=>{D.current!==Z&&(D.current=Z,w.reset(),A(new Set),J(0))},[Z,w]),Q(()=>{if(!ae)return;const $=me=>{const be=fe.current;be&&me.target instanceof Node&&!be.contains(me.target)&&pe(!1)};return document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[ae]);const F=q(()=>{const $={};return e&&($.agentId=e),t&&($.addonId=t),r!==void 0&&($.deviceId=r),a&&($.category=a),$},[e,t,r,a]),O=q(()=>[...v].sort(),[v]),ie=q(()=>{const $={...F,limit:c};return O.length>0&&O.length<Mt.length&&($.category=O),$},[F,c,q(()=>O.join(","),[O]),O]),{data:_,isLoading:L}=f.systemEvents.getRecent.useQuery(ie,{staleTime:3e4}),G=W(v);Q(()=>{G.current=v},[v]);const B=F;f.systemEvents.subscribe.useSubscription(B,{onData:$=>{const me=$;me?.id&&Mb(me,e,t,r)&&G.current.has(me.category)&&w.append(me)}});const te=W(N.length);Q(()=>{const $=K.current;if(!$){te.current=N.length;return}const me=te.current;if(te.current=N.length,!(N.length<=me)){if(S&&$.scrollTop<=8)$.scrollTo({top:0});else if(!S&&$.scrollTop>0){const be=$.firstElementChild?.firstElementChild,ye=be instanceof HTMLElement?be.offsetHeight:28;$.scrollTop+=ye*(N.length-me)}}},[N.length,S]);const X=q(()=>{const $=new Map;for(const ye of _??[])$.set(ye.id,ye);for(const ye of N)$.set(ye.id,ye);let me=[...$.values()].filter(ye=>v.has(ye.category)).filter(_b);oe>0&&(me=me.filter(ye=>new Date(ye.timestamp).getTime()>oe));const be=V.trim().toLowerCase();return be&&(me=me.filter(ye=>{if(ye.category.toLowerCase().includes(be)||Fn(ye.category,ye.data).label.toLowerCase().includes(be))return!0;const pt=Er(ye.category,ye.data);if(pt&&pt.toLowerCase().includes(be))return!0;try{if(new Date(ye.timestamp).toLocaleTimeString().toLowerCase().includes(be))return!0}catch{}try{if(JSON.stringify(ye.data).toLowerCase().includes(be)||JSON.stringify(ye.source).toLowerCase().includes(be))return!0}catch{}return!1})),me.sort((ye,pt)=>new Date(pt.timestamp).getTime()-new Date(ye.timestamp).getTime())},[_,N,v,V,oe]),Le=R($=>{A(me=>{const be=new Set(me);return be.has($)?be.delete($):be.add($),be})},[]),Oe=R($=>{y(me=>{const be=new Set(me);return be.has($)?be.delete($):be.add($),be})},[]),ee=R(()=>{y(new Set(g)),H(""),J(0)},[g]),he=R(()=>{J(Date.now()),w.reset()},[w]),[ke,Ne]=E(!1),[Ie,T]=E(null),le=R($=>{const me=new Date($.timestamp).toISOString(),be=Er($.category,$.data)??"",ye=be?` ${be}`:"";return`${me} [${$.category}]${ye} data=${JSON.stringify($.data)}`},[]),ge=R(()=>{const $=X.map(le);navigator.clipboard.writeText($.join(`
|
|
87
|
+
`)).then(()=>{Ne(!0),setTimeout(()=>Ne(!1),1500)})},[X,le]),ve=R($=>{navigator.clipboard.writeText(le($)).then(()=>{T($.id),setTimeout(()=>T(me=>me===$.id?null:me),1200)})},[le]),z=R(()=>{y(new Set(Mt))},[]),re=R(()=>{y(new Set)},[]),xe=q(()=>{const $=ne.trim().toLowerCase();return $?Mt.filter(me=>me.toLowerCase().includes($)):Mt},[ne]),Ye=Mt.length,$e=v.size,Nt=$e===Ye,Ol=Nt?"All":`${$e}/${Ye}`;return m("div",{className:C("h-full min-h-0 flex flex-col",h),onClick:$=>$.stopPropagation(),children:[m("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"Events"}),e&&o(br,{label:"agent",value:e}),t&&o(br,{label:"addon",value:t}),r!==void 0&&o(br,{label:"device",value:`#${r}`}),a&&o(br,{label:"category",value:a}),m("button",{type:"button",onClick:()=>{M($=>!$),!S&&K.current&&K.current.scrollTo({top:0,behavior:"smooth"})},className:C("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",S?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[o(Ya,{className:"h-2.5 w-2.5"}),S?"Auto":"Paused"]}),l&&m("div",{className:"relative",ref:fe,children:[m("button",{type:"button",onClick:()=>pe($=>!$),className:C("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",Nt?"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:[o(ri,{className:"h-2.5 w-2.5"}),"Filter (",Ol,")"]}),ae&&o(Tb,{search:ne,onSearchChange:se,categories:xe,active:v,onToggle:Oe,onSelectAll:z,onSelectNone:re,onResetDefaults:ee})]}),m("button",{type:"button",onClick:ee,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:[o(li,{className:"h-2.5 w-2.5"}),"Reset"]}),m("button",{type:"button",onClick:he,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:[o(et,{className:"h-2.5 w-2.5"}),"Clear"]}),m("button",{type:"button",onClick:ge,disabled:X.length===0,className:C("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",ke?"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 events",children:[o(dt,{className:"h-2.5 w-2.5"}),ke?"Copied!":"Copy"]}),m("div",{className:"relative",children:[o("input",{type:"text",value:V,onChange:$=>H($.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"}),V&&o("button",{type:"button",onClick:()=>H(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(_e,{className:"h-2.5 w-2.5"})})]}),N.length>0&&m("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",N.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(_e,{className:"h-3.5 w-3.5"})})]}),m("div",{ref:K,className:C("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[L&&m("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle",children:[o(Fe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading events..."]}),!L&&X.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),X.length>0&&o("div",{className:"divide-y divide-border/30",children:X.map($=>{const me=Fn($.category,$.data),be=me.icon,ye=Er($.category,$.data),pt=P.has($.id);return m("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>Le($.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date($.timestamp).toLocaleTimeString()}),o(Db,{copied:Ie===$.id,onCopy:()=>ve($)}),m("div",{className:"flex-1 min-w-0",children:[m("div",{className:"flex items-center gap-1.5",children:[pt?o(xt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(ut,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),m("span",{className:C("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",me.color),children:[o(be,{className:"h-2.5 w-2.5"}),me.label]}),$.source.nodeId&&$.source.nodeId!=="hub"&&o("span",{className:"text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono",children:$.source.nodeId})]}),ye&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:ye}),pt&&m("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:[m("div",{children:[o("span",{className:"text-primary/70",children:"source"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:JSON.stringify($.source)})]}),m("div",{children:[o("span",{className:"text-primary/70",children:"category"}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground",children:$.category})]}),Object.entries($.data).map(([mo,Ur])=>m("div",{children:[o("span",{className:"text-primary/70",children:mo}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:typeof Ur=="object"?JSON.stringify(Ur):String(Ur)})]},mo))]})]})]},$.id)})})]})]})}function Tb({search:e,onSearchChange:t,categories:r,active:n,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:c}){return m("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:l=>l.stopPropagation(),children:[m("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[o(er,{className:"h-3 w-3 text-foreground-subtle"}),o("input",{type:"text",value:e,onChange:l=>t(l.target.value),placeholder:"Filter categories…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&o("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:o(_e,{className:"h-2.5 w-2.5"})})]}),m("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[o("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),o("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),o("button",{type:"button",onClick:c,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),m("div",{className:"overflow-y-auto flex-1",children:[r.length===0&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),r.map(l=>{const u=n.has(l),d=Fn(l),p=d.icon;return m("button",{type:"button",onClick:()=>s(l),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[o("input",{type:"checkbox",readOnly:!0,checked:u,className:"accent-violet-500"}),m("span",{className:C("inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0",d.color),children:[o(p,{className:"h-2.5 w-2.5"}),d.label]}),o("span",{className:"text-foreground-subtle font-mono truncate",children:l})]},l)})]})]})}function U5({position:e="bottom",className:t,...r}){return o("div",{className:C(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",t),children:o(_l,{maxHeight:"max-h-48",...r})})}function br({label:e,value:t}){return m("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium",children:[e,": ",t]})}function Db({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this event",onClick:r=>{r.stopPropagation(),t()},className:C("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?o(sr,{className:"h-3 w-3"}):o(dt,{className:"h-3 w-3"})})}function H5({deviceId:e,className:t="",onOpenChild:r}){const n=f.useUtils(),s=f.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),a=f.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),i=f.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{n.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),n.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),c=f.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{n.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),l=f.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{n.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[u,d]=E(null),{available:p,adopted:h}=q(()=>{const w=s.data??[],N=M=>typeof M.metadata.rtspChannel=="number"?M.metadata.rtspChannel:Number.POSITIVE_INFINITY,S=(M,P)=>{const A=N(M),V=N(P);return A!==V?A-V:M.name.localeCompare(P.name)};return{available:w.filter(M=>!M.alreadyAdopted).sort(S),adopted:w.filter(M=>M.alreadyAdopted).sort(S)}},[s.data]),g=a.data,b=g?.lastError??null,v=g?.lastDiscoveryAt??null;async function y(){await i.mutateAsync({deviceId:e}).catch(()=>{})}async function x(w){d(w.childNativeId);try{await c.mutateAsync({deviceId:e,childNativeId:w.childNativeId})}finally{d(null)}}async function k(w){if(w.adoptedDeviceId!=null){d(w.childNativeId);try{await l.mutateAsync({deviceId:e,childDeviceId:w.adoptedDeviceId})}finally{d(null)}}}return m("div",{className:`rounded-xl border border-border bg-surface ${t}`,children:[m("div",{className:"flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3",children:[m("div",{className:"min-w-0",children:[o("h3",{className:"text-sm font-semibold text-foreground",children:"Discovered devices"}),m("p",{className:"text-[11px] text-foreground-subtle",children:["Channels behind this hub. Click ",o("span",{className:"font-medium",children:"Add"})," to promote a channel to a managed device, or ",o("span",{className:"font-medium",children:"Remove"})," to detach."]})]}),m("button",{type:"button",onClick:y,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?o(Fe,{className:"h-3.5 w-3.5 animate-spin"}):o(Br,{className:"h-3.5 w-3.5"}),o("span",{className:"hidden sm:inline",children:"Refresh"})]})]}),b?m("div",{className:"flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive",children:[o(Ft,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),m("span",{children:["Last refresh failed: ",b]})]}):null,s.isLoading?o("div",{className:"flex items-center justify-center py-8 text-foreground-subtle",children:o(Fe,{className:"h-5 w-5 animate-spin"})}):p.length===0&&h.length===0?o("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."}):m(we,{children:[p.length>0?o(As,{title:"Available to add",count:p.length,tone:"primary",children:p.map(w=>o(Ps,{child:w,busy:u===w.childNativeId,onAdopt:x,onRelease:k,onOpenChild:r},w.childNativeId))}):null,h.length>0?o(As,{title:"Already adopted",count:h.length,tone:"muted",children:h.map(w=>o(Ps,{child:w,busy:u===w.childNativeId,onAdopt:x,onRelease:k,onOpenChild:r},w.childNativeId))}):null]}),v!=null?m("div",{className:"border-t border-border px-5 py-2 text-[10px] text-foreground-subtle",children:["Last refreshed ",new Date(v).toLocaleString()]}):null]})}function As({title:e,count:t,tone:r,children:n}){return m("div",{className:"border-t border-border",children:[m("div",{className:`flex items-center justify-between border-b px-3 sm:px-5 py-1.5 text-[10px] uppercase tracking-wider ${r==="primary"?"bg-primary/5 text-primary border-primary/30":"bg-surface text-foreground-subtle border-border"}`,children:[o("span",{className:"font-semibold",children:e}),o("span",{className:"font-mono",children:t})]}),o("div",{className:"divide-y divide-border",children:n})]})}function Ps({child:e,busy:t,onAdopt:r,onRelease:n,onOpenChild:s}){return m("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:[m("div",{className:"min-w-0 flex-1",children:[m("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[o(Lb,{status:e.status}),o("span",{className:"truncate text-sm font-medium text-foreground",children:e.name}),e.metadata.isDoorbell?o("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?o("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?o("span",{className:"rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle",children:"Multifocal"}):null]}),m("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"?m("span",{children:["ch ",o("span",{className:"font-mono",children:e.metadata.rtspChannel})]}):null,e.metadata.model?o("span",{className:"truncate max-w-[160px]",children:e.metadata.model}):null,e.metadata.uid?m("span",{className:"font-mono truncate max-w-[140px]",children:[e.metadata.uid.slice(0,12),"…"]}):null]})]}),e.alreadyAdopted?m("div",{className:"flex items-center gap-2",children:[s&&e.adoptedDeviceId!==null?m("button",{type:"button",onClick:()=>s(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:[o(eo,{className:"h-3.5 w-3.5"}),"Open"]}):null,m("button",{type:"button",onClick:()=>{n(e)},disabled:t,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:[t?o(Fe,{className:"h-3.5 w-3.5 animate-spin"}):o(et,{className:"h-3.5 w-3.5"}),"Remove"]})]}):m("button",{type:"button",onClick:()=>{r(e)},disabled:t,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:[t?o(Fe,{className:"h-3.5 w-3.5 animate-spin"}):o(zt,{className:"h-3.5 w-3.5"}),"Add"]})]})}function Lb({status:e}){switch(e){case"online":return m("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:[o(pi,{className:"h-2.5 w-2.5"})," online"]});case"sleeping":return m("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:[o(ro,{className:"h-2.5 w-2.5"})," sleeping"]});case"offline":return m("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:[o(Op,{className:"h-2.5 w-2.5"})," offline"]});default:return m("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:[o(Ja,{className:"h-2.5 w-2.5"})," unknown"]})}}function Ob(e,t){if(!e||typeof e!="object")return null;const r=e;if(r.category!==Y.DeviceStateChanged)return null;const n=r.data;return!n||typeof n!="object"||n.deviceId!==t||typeof n.capName!="string"||!n.slice||typeof n.slice!="object"?null:{capName:n.capName,slice:n.slice}}function $b(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var Bb=Object.freeze([...new Set(ql.filter(e=>e.scope==="device").map(e=>e.name))].sort()),zb=1;function Fb({deviceId:e,defaultCaps:t,maxHeight:r="max-h-96",onClose:n,className:s}){const[a,i]=E(q(()=>new Set(t??[]),[t])),[c,l]=E(""),[u,d]=E(!1),[p,h]=E(""),g=W(null),[b,v]=E(new Map),[y,x]=E(new Map),[,k]=E(0),w=W(e);Q(()=>{w.current!==e&&(w.current=e,v(new Map),x(new Map))},[e]);const{data:N,isLoading:S}=f.deviceState.getAllSnapshots.useQuery({},{staleTime:3e4}),M=W(!1);Q(()=>{if(M.current||!$b(N))return;const _=N[String(e)];if(M.current=!0,!_)return;const L=Date.now();v(G=>{const B=new Map(G);for(const[te,X]of Object.entries(_))B.has(te)||B.set(te,{slice:X,updatedAt:L});return B})},[N,e]),Q(()=>{M.current=!1},[e]),f.systemEvents.subscribe.useSubscription({deviceId:e,category:Y.DeviceStateChanged},{onData:_=>{const L=Ob(_,e);L&&v(G=>{const B=new Map(G);return B.set(L.capName,{slice:L.slice,updatedAt:Date.now()}),B})}}),Q(()=>{const _=setInterval(()=>k(L=>L+1),5e3);return()=>clearInterval(_)},[]);const P=q(()=>{const _=new Set(Bb);for(const L of b.keys())_.add(L);return[..._].sort()},[b]),A=q(()=>{const _=c.trim().toLowerCase();return[...b.keys()].sort().filter(L=>a.size>0&&!a.has(L)?!1:!_||L.toLowerCase().includes(_)?!0:Qn(b.get(L)?.slice??{},_))},[b,a,c]),V=R(_=>{i(L=>{const G=new Set(L);return G.has(_)?G.delete(_):G.add(_),G})},[]),H=R(()=>{i(new Set(t??[])),l("")},[t]),ae=R(()=>{i(new Set(P))},[P]),pe=R(()=>{i(new Set)},[]),ne=R((_,L)=>{x(G=>{const B=new Map(G);return B.set(_,!L),B})},[]),se=R((_,L)=>{const G=y.get(_);return G!==void 0?G:L<zb},[y]),[oe,J]=E(!1),K=R(()=>{const _={};for(const L of A){const G=b.get(L);G&&(_[L]=G.slice)}navigator.clipboard.writeText(JSON.stringify(_,null,2)).then(()=>{J(!0),setTimeout(()=>J(!1),1500)})},[A,b]),fe=q(()=>{const _=p.trim().toLowerCase();return _?P.filter(L=>L.toLowerCase().includes(_)):P},[p,P]),Z=P.length,D=a.size,F=D===0||D===Z,O=F?"All":`${D}/${Z}`;Q(()=>{if(!u)return;const _=L=>{const G=g.current;G&&!G.contains(L.target)&&d(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[u]);const ie=c.trim().toLowerCase();return m("div",{className:C("h-full min-h-0 flex flex-col",s),onClick:_=>_.stopPropagation(),children:[m("div",{className:"flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0",children:[m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"text-[10px] uppercase tracking-wide text-foreground-subtle font-medium",children:"State"}),o(Hb,{label:"device",value:`#${e}`}),m("div",{className:"relative",ref:g,children:[m("button",{type:"button",onClick:()=>d(_=>!_),className:C("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-violet-500/30 bg-violet-500/10 text-violet-400"),title:"Pick caps to show",children:[o(ri,{className:"h-2.5 w-2.5"}),"Filter (",O,")"]}),u&&o(Vb,{search:p,onSearchChange:h,caps:fe,active:a,onToggle:V,onSelectAll:ae,onSelectNone:pe,onResetDefaults:H})]}),m("button",{type:"button",onClick:H,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:[o(li,{className:"h-2.5 w-2.5"}),"Reset"]}),m("button",{type:"button",onClick:K,disabled:A.length===0,className:C("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",oe?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",A.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy visible state as JSON",children:[o(dt,{className:"h-2.5 w-2.5"}),oe?"Copied!":"Copy"]}),m("div",{className:"relative",children:[o("input",{type:"text",value:c,onChange:_=>l(_.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"}),c&&o("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:o(_e,{className:"h-2.5 w-2.5"})})]}),m("span",{className:"text-[9px] text-emerald-400 font-medium inline-flex items-center gap-1",children:[o("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"}),"live"]})]}),n&&o("button",{type:"button",onClick:n,className:"text-foreground-subtle hover:text-foreground",children:o(_e,{className:"h-3.5 w-3.5"})})]}),m("div",{className:C("flex-1 min-h-0 overflow-auto text-[10px] font-mono",r),children:[S&&b.size===0&&m("div",{className:"flex items-center justify-center gap-2 py-6 text-foreground-subtle font-sans",children:[o(Fe,{className:"h-3.5 w-3.5 animate-spin"}),"Loading device state..."]}),!S&&b.size===0&&o("div",{className:"py-4 text-center text-foreground-subtle font-sans",children:"No runtime state"}),!S&&b.size>0&&A.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle font-sans",children:"No caps match the filter"}),A.length>0&&o("div",{className:"py-1",children:A.map(_=>{const L=b.get(_);return L?o(Gb,{capName:_,slice:L.slice,updatedAt:L.updatedAt,searchNeedle:ie,isPathOpen:se,onToggle:ne},_):null})})]})]})}function Gb({capName:e,slice:t,updatedAt:r,searchNeedle:n,isPathOpen:s,onToggle:a}){const i=e,c=s(i,0),l=Object.entries(t);return m("div",{children:[m("div",{className:"flex items-center gap-1.5 px-3 py-1 hover:bg-surface-hover/30 cursor-pointer select-none",onClick:()=>a(i,c),children:[o(Dl,{open:c,hasChildren:l.length>0}),o("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 font-sans",children:e}),m("span",{className:"text-[9px] text-foreground-subtle font-sans",children:[l.length," ",l.length===1?"key":"keys"]}),m("span",{className:"ml-auto text-[9px] text-foreground-subtle/70 font-sans tabular-nums",children:["updated ",Ub(r)]})]}),c&&o("div",{children:l.length===0?o(Tl,{depth:1,label:"empty slice"}):l.map(([u,d])=>o(Il,{path:`${i}.${u}`,nodeKey:u,value:d,depth:1,searchNeedle:n,isPathOpen:s,onToggle:a},u))})]})}function Il({path:e,nodeKey:t,value:r,depth:n,searchNeedle:s,isPathOpen:a,onToggle:i}){const c=Qb(r),l={paddingLeft:`${12+n*14}px`};if(!c)return m("div",{className:"flex items-start gap-1 px-3 py-0.5",style:l,children:[o("span",{className:C("shrink-0",fn(t,s,"text-primary/70")),children:t}),o("span",{className:"text-foreground-subtle",children:":"}),o("span",{className:C("break-all",fn(Gn(r),s,jb(r))),children:Gn(r)})]});const u=a(e,n);return m("div",{children:[m("div",{className:"flex items-center gap-1 px-3 py-0.5 hover:bg-surface-hover/30 cursor-pointer select-none",style:l,onClick:()=>i(e,u),children:[o(Dl,{open:u,hasChildren:c.entries.length>0}),o("span",{className:fn(t,s,"text-primary/70"),children:t}),o("span",{className:"text-foreground-subtle/70 text-[9px]",children:c.summary})]}),u&&(c.entries.length===0?o(Tl,{depth:n+1,label:c.kind==="array"?"empty array":"empty object"}):c.entries.map(([d,p])=>o(Il,{path:`${e}.${d}`,nodeKey:d,value:p,depth:n+1,searchNeedle:s,isPathOpen:a,onToggle:i},d)))]})}function Tl({depth:e,label:t}){return o("div",{className:"px-3 py-0.5 text-foreground-subtle/60 italic",style:{paddingLeft:`${12+e*14}px`},children:t})}function Dl({open:e,hasChildren:t}){return t?e?o(xt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(ut,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o("span",{className:"inline-block w-3 shrink-0"})}function Qb(e){if(Array.isArray(e))return{kind:"array",entries:e.map((t,r)=>[String(r),t]),summary:`[${e.length}]`};if(e&&typeof e=="object"){const t=Object.entries(e);return{kind:"object",entries:t,summary:`{${t.length}}`}}return null}function Gn(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 jb(e){return e==null?"text-foreground-subtle/60":typeof e=="number"?"text-amber-400":typeof e=="boolean"?e?"text-emerald-400":"text-rose-400":"text-foreground"}function fn(e,t,r){return t&&e.toLowerCase().includes(t)?C(r,"bg-violet-500/20 rounded px-0.5"):r}function Qn(e,t){if(Array.isArray(e))return e.some(r=>Qn(r,t));if(e&&typeof e=="object"){for(const[r,n]of Object.entries(e))if(r.toLowerCase().includes(t)||Qn(n,t))return!0;return!1}return Gn(e).toLowerCase().includes(t)}function Ub(e){const t=Date.now()-e;if(t<5e3)return"just now";const r=Math.floor(t/1e3);if(r<60)return`${r}s ago`;const n=Math.floor(r/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function Hb({label:e,value:t}){return m("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium font-sans",children:[e,": ",t]})}function Vb({search:e,onSearchChange:t,caps:r,active:n,onToggle:s,onSelectAll:a,onSelectNone:i,onResetDefaults:c}){return m("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 font-sans",onClick:l=>l.stopPropagation(),children:[m("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border/50",children:[o(er,{className:"h-3 w-3 text-foreground-subtle"}),o("input",{type:"text",value:e,onChange:l=>t(l.target.value),placeholder:"Filter caps…",className:"flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle",autoFocus:!0}),e&&o("button",{type:"button",onClick:()=>t(""),className:"text-foreground-subtle hover:text-foreground",children:o(_e,{className:"h-2.5 w-2.5"})})]}),m("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]",children:[o("button",{type:"button",onClick:a,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"All"}),o("button",{type:"button",onClick:i,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"None"}),o("button",{type:"button",onClick:c,className:"px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground",children:"Defaults"})]}),m("div",{className:"overflow-y-auto flex-1",children:[r.length===0&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-3 text-center",children:"No matches"}),r.map(l=>m("button",{type:"button",onClick:()=>s(l),className:"w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]",children:[o("input",{type:"checkbox",readOnly:!0,checked:n.has(l),className:"accent-violet-500"}),o("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:l})]},l))]})]})}var mn=500,qb=[{id:"logs",label:"Logs",icon:Sp},{id:"events",label:"Events",icon:$r},{id:"state",label:"State",icon:lp}];function V5({deviceId:e,defaultEventCategories:t,defaultStateCaps:r,initialTab:n="events",className:s,maxHeight:a="max-h-96"}){const[i,c]=E(n),l=Wt(mn),u=Wt(mn),d=Wt(mn),p=l.reset,h=u.reset,g=d.reset;return Q(()=>{p(),h(),g()},[e,p,h,g]),m("div",{className:C("flex flex-col h-full min-h-0",s),children:[o("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:qb.map(({id:b,label:v,icon:y})=>m("button",{type:"button",onClick:()=>c(b),className:C("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:[o(y,{className:"h-3.5 w-3.5"}),v]},b))}),m("div",{className:"flex-1 min-h-0 overflow-hidden",children:[i==="logs"&&o(Rl,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:l}),i==="events"&&o(_l,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:u}),i==="state"&&o(Fb,{deviceId:e,defaultCaps:r,maxHeight:a,liveBuffer:d})]})]})}function q5({label:e,icon:t,title:r="Confirm action",description:n,confirmLabel:s,triggerVariant:a="outline",confirmVariant:i="danger",size:c="sm",disabled:l,className:u,action:d,onSuccess:p}){const[h,g]=E(!1),[b,v]=E(!1),[y,x]=E(null),k=async()=>{x(null),v(!0);try{const w=await d();p?.(w),g(!1)}catch(w){x(w instanceof Error?w.message:String(w))}finally{v(!1)}};return m(we,{children:[m(at,{type:"button",variant:a,size:c,disabled:l,onClick:()=>{x(null),g(!0)},className:u,children:[t&&o(t,{className:"h-3.5 w-3.5"}),e]}),o(Wp,{open:h,onOpenChange:w=>!b&&g(w),children:m(yi,{children:[m(Zp,{children:[m(Xp,{className:"flex items-center gap-2",children:[o(Ft,{className:"h-4 w-4 text-amber-400"}),r]}),typeof n=="string"?o(Jp,{children:n}):n]}),y&&o("div",{className:C("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:y}),m(Yp,{children:[o(at,{type:"button",variant:"ghost",size:c,disabled:b,onClick:()=>g(!1),children:"Cancel"}),m(at,{type:"button",variant:i,size:c,disabled:b,onClick:()=>{k()},children:[b&&o(Fe,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function Wb(e,t){const r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r)}function W5({trpc:e,deviceId:t,deviceName:r,size:n="sm",className:s}){const[a,i]=E(!1),[c,l]=E(!1),[u,d]=E(null),p=r.replace(/[^a-zA-Z0-9_.-]+/g,"_"),h=R(async S=>{i(!0),d(null),l(!1);try{const M=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!M)throw new Error("No snapshot available");const P=`data:${M.contentType};base64,${M.base64}`;if(S==="copy")try{await navigator.clipboard.writeText(P)}catch{throw new Error("Clipboard unavailable")}else{const A=M.contentType.includes("png")?"png":"jpg";Wb(`${p}-${new Date().toISOString().replace(/[:.]/g,"-")}.${A}`,P)}l(!0),setTimeout(()=>l(!1),1500)}catch(M){d(M instanceof Error?M.message:String(M))}finally{i(!1)}},[e,t,p]),g=n==="md"?"h-9 px-3 text-sm gap-2":"h-7 px-2.5 text-[11px] gap-1.5",[b,v]=E(null),[y,x]=E(!1),k=()=>{x(!1),v(setTimeout(()=>{x(!0),h("copy")},600))},w=()=>{b&&(clearTimeout(b),v(null)),y||h("download")},N=()=>{b&&(clearTimeout(b),v(null))};return m("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:k,onPointerUp:w,onPointerLeave:N,onPointerCancel:N,className:C("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",g,u&&"border-danger/40 text-danger",s),children:[a?o(Fe,{className:"h-3.5 w-3.5 animate-spin"}):c?o(sr,{className:"h-3.5 w-3.5 text-success"}):o(Xn,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function Kb(e){const t=Date.now()-e;return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function K5({history:e,limit:t=5,latestIsFresh:r,className:n}){if(e.length===0)return null;const s=r?Zd:$r,a=e.slice(0,t);return m("div",{className:C("rounded-lg border border-border bg-surface px-3 py-2",n),children:[m("div",{className:"flex items-center gap-2 mb-2",children:[o(s,{className:C("h-4 w-4 text-amber-400",r&&"animate-pulse")}),o("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle",children:"Recent presses"}),o("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})]}),o("ul",{className:"space-y-1",children:a.map(i=>m("li",{className:"flex items-center justify-between text-[11px]",title:new Date(i.timestamp).toLocaleString(),children:[o("span",{className:"text-foreground",children:Kb(i.timestamp)}),o("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function Z5({items:e,header:t,triggerClassName:r,title:n="More actions"}){const[s,a]=E(!1),i=e.filter(c=>!c.hidden);return i.length===0?null:m(ef,{open:s,onOpenChange:a,children:[o(tf,{title:n,className:C("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",r),children:o(ti,{className:"h-4 w-4"})}),m(rf,{className:"left-auto right-0 mt-1 min-w-[200px] p-1",children:[t&&o("div",{className:"px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle",children:t}),o("ul",{className:"space-y-0.5",children:i.map((c,l)=>m("li",{children:[c.separatorBefore&&l>0&&o("div",{className:"my-1 h-px bg-border"}),m("button",{type:"button",disabled:c.disabled,onClick:()=>{c.disabled||(c.onClick(),a(!1))},className:C("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",c.danger?"text-foreground hover:bg-danger/10 hover:text-danger":"text-foreground hover:bg-surface-hover"),children:[c.icon&&o(c.icon,{className:C("h-3.5 w-3.5 shrink-0 mt-0.5",c.danger&&"text-danger/80")}),m("span",{className:"flex-1 min-w-0",children:[o("span",{className:"block leading-tight",children:c.label}),c.description&&o("span",{className:"block mt-0.5 text-[10px] text-foreground-subtle leading-tight",children:c.description})]})]})]},c.id))})]})]})}var Zb=[{value:"view",label:"View",icon:Bt,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:bp,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:et,hint:"Destructive ops (delete/revoke/reset/…)"}],Yb=["device","system"];function Xb(){return{type:"capability",target:"",access:["view"]}}function Jb(e){if(e==null)return[];const t=new Set;for(const r of e)if(r.type==="device")for(const n of r.targets)t.add(n);return[...t]}function ev(e,t,r,n){let s;switch(e){case"addon":s=r;break;case"capability":s=n;break;case"category":s=Yb.map(i=>({value:i,label:i}));break}if(t==null)return s;const a=new Set(t.filter(i=>i.type!=="device"&&i.type===e).map(i=>i.target));return s.filter(i=>a.has(i.value))}function tv(e,t){if(t==null)return["view","create","delete"];const r=t.filter(s=>s.type!==e.type?!1:s.type==="device"&&e.type==="device"?s.targets.some(a=>e.targets.includes(a)):s.type!=="device"&&e.type!=="device"?s.target===e.target:!1);if(r.length===0)return[];const n=new Set;for(const s of r)for(const a of s.access)n.add(a);return[...n]}function Y5({value:e,onChange:t,clampToParent:r,emptyHint:n}){const{data:s}=xh(),{data:a}=Mh({}),i=q(()=>(s??[]).map(b=>({value:b.manifest.id,label:b.manifest.id})).sort((b,v)=>b.label.localeCompare(v.label)),[s]),c=q(()=>[...Vl].sort().map(b=>({value:b,label:b})),[]),l=q(()=>(a??[]).map(b=>({value:String(b.id),label:`${b.name} (#${b.id} · ${b.addonId})`})).sort((b,v)=>b.label.localeCompare(v.label)),[a]),u=q(()=>r==null?null:Jb(r),[r]),d=(b,v)=>{const y=[...v];switch(b){case"category":return{type:"category",target:"device",access:y};case"capability":return{type:"capability",target:"",access:y};case"addon":return{type:"addon",target:"",access:y};case"device":return{type:"device",targets:[],access:y}}},p=(b,v)=>{t(e.map((y,x)=>{if(x!==b)return y;if(v.type!==void 0&&v.type!==y.type)return d(v.type,v.access??y.access);const k=[...v.access??y.access];return y.type==="device"?{type:"device",targets:[...v.targets??y.targets],access:k}:y.type==="category"?{type:"category",target:v.target??y.target,access:k}:y.type==="capability"?{type:"capability",target:v.target??y.target,access:k}:{type:"addon",target:v.target??y.target,access:k}}))},h=b=>{t(e.filter((v,y)=>y!==b))},g=()=>{t([...e,Xb()])};return m("div",{className:"space-y-2",children:[e.length===0&&n&&o("div",{className:"text-[10px] text-foreground-subtle italic px-2 py-2",children:n}),e.map((b,v)=>{const y=tv(b,r);return m("div",{className:"flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5",children:[m("select",{value:b.type,onChange:x=>p(v,{type:x.target.value}),className:"rounded border border-border bg-background px-2 py-1 text-[11px] focus:outline-none focus:ring-1 focus:ring-primary",children:[o("option",{value:"category",children:"category"}),o("option",{value:"capability",children:"capability"}),o("option",{value:"addon",children:"addon"}),o("option",{value:"device",children:"device"})]}),b.type==="device"?o(rv,{value:b.targets,choices:l,clampToParent:u,onChange:x=>p(v,{targets:x})}):m("select",{value:b.target,onChange:x=>p(v,{target:x.target.value}),className:"flex-1 min-w-[160px] rounded border border-border bg-background px-2 py-1 text-[11px] font-mono focus:outline-none focus:ring-1 focus:ring-primary",children:[m("option",{value:"",children:["— pick ",b.type," —"]}),ev(b.type,r,i,c).map(x=>o("option",{value:x.value,children:x.label},x.value))]}),o("div",{className:"flex items-center gap-1",children:Zb.map(({value:x,label:k,icon:w,hint:N})=>{const S=b.access.includes(x),M=r!=null&&!y.includes(x)&&!S;return m("label",{title:M?`${N} — not granted by your scope`:N,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${S?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${M?"opacity-40 cursor-not-allowed":""}`,children:[o("input",{type:"checkbox",checked:S,disabled:M,onChange:P=>{const A=new Set(b.access);P.target.checked?A.add(x):A.delete(x),p(v,{access:[...A]})},className:"sr-only"}),o(w,{className:"h-3 w-3"}),k]},x)})}),o("button",{type:"button",onClick:()=>h(v),className:"rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors",title:"Remove scope",children:o(_e,{className:"h-3 w-3"})})]},v)}),m("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-foreground-subtle hover:text-foreground hover:bg-foreground-subtle/10 transition-colors",children:[o(zt,{className:"h-3 w-3"}),"Add scope"]})]})}function rv({value:e,choices:t,clampToParent:r,onChange:n}){const[s,a]=E(""),i=q(()=>{const d=r==null?t:t.filter(h=>r.includes(h.value)),p=new Set(e);return d.filter(h=>!p.has(h.value))},[t,r,e]),c=d=>t.find(p=>p.value===d)?.label??`#${d}`,l=d=>{d&&(n([...e,d]),a(""))},u=d=>{n(e.filter(p=>p!==d))};return m("div",{className:"flex-1 min-w-[160px] flex flex-wrap items-center gap-1",children:[e.length===0&&o("span",{className:"text-[10px] text-foreground-subtle italic px-1",children:"no devices selected"}),e.map(d=>m("span",{className:"inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-mono text-primary",children:[c(d),o("button",{type:"button",onClick:()=>u(d),className:"hover:text-danger transition-colors",title:"Remove device",children:o(_e,{className:"h-2.5 w-2.5"})})]},d)),i.length>0&&m("select",{value:s,onChange:d=>l(d.target.value),className:"rounded border border-border bg-background px-1.5 py-0.5 text-[10px] focus:outline-none focus:ring-1 focus:ring-primary",children:[o("option",{value:"",children:"+ add device…"}),i.map(d=>o("option",{value:d.value,children:d.label},d.value))]})]})}function X5(e){for(const t of e){if(t.type==="device"){if(t.targets.length===0)return"Scope device: pick at least one device"}else if(t.target.trim().length===0)return`Scope ${t.type}: pick a target`;if(t.access.length===0){const r=t.type==="device"?`[${t.targets.join(",")}]`:t.target;return`Scope ${t.type}:${r}: pick at least one access`}}return null}var Ll=ct("camstack:zone-editing",null);function J5({children:e}){const[t,r]=E(!1),[n,s]=E(null),[a,i]=E(null),[c,l]=E(null),u=R(k=>{r(k),k||(s(null),i(null),l(null))},[]),d=R(k=>{s(k)},[]),p=R(k=>{i(k)},[]),h=R(k=>{r(!0),i(null),s(k),l(null)},[]),g=R(()=>{r(!1),s(null),i(null),l(null)},[]),b=R(k=>{i(k.id),l(k)},[]),v=R(k=>{l(w=>w===null?w:{...w,...k})},[]),y=R(()=>{l(null)},[]),x=q(()=>({editing:t,drawingKind:n,selectedZoneId:a,editingDraft:c,setEditing:u,setDrawingKind:d,setSelectedZoneId:p,startDrawing:h,exitEditing:g,enterDraft:b,updateDraft:v,discardDraft:y}),[t,n,a,c,u,d,p,h,g,b,v,y]);return o(Ll.Provider,{value:x,children:e})}function eM(){return Re(Ll)}var Rs=500,nv=800;function vr(e,t,r){try{const n=e.live;if(!n)return null;const s=n.onEvent;return!s||typeof s.subscribe!="function"?null:s.subscribe({category:t},{onData:r})}catch{return null}}function yr(e,t){return e?.id===t}function tM(e,t){const[r,n]=E(null),[s,a]=E(null),[i,c]=E(null),[l,u]=E("watching"),d=W(void 0),p=W(void 0),h=W(void 0);return Q(()=>{if(t===null)return;const g=vr(e,"detection.motion-analysis",b=>{const v=b;if(!yr(v?.source,t))return;const y=v.data;!y?.regions||y.regions.length===0||(n({zones:y.regions.map(x=>({...x.bbox,intensity:x.intensity})),frameWidth:y.frameWidth,frameHeight:y.frameHeight}),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>n(null),Rs))});return()=>{g?.unsubscribe(),d.current&&clearTimeout(d.current)}},[e,t]),Q(()=>{if(t===null)return;const g=vr(e,"detection.motion-zones-raw",b=>{const v=b;if(!yr(v?.source,t))return;const y=v.data;y?.zones&&(a({boxes:y.zones.map(x=>({bbox:x.bbox,changeScore:x.changeScore})),frameWidth:y.frameSize?.width??0,frameHeight:y.frameSize?.height??0,motionScore:y.zones.length>0?y.zones.reduce((x,k)=>x+k.changeScore,0)/y.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),Rs))});return()=>{g?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Q(()=>{if(t===null)return;const g=vr(e,"detection.result",b=>{const v=b;if(!yr(v?.source,t))return;const y=v.data?.frame;y?.detections?.length&&(c({detections:y.detections,frameWidth:y.width,frameHeight:y.height}),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>c(null),nv))});return()=>{g?.unsubscribe(),h.current&&clearTimeout(h.current)}},[e,t]),Q(()=>{if(t===null)return;const g=vr(e,"detection.phase-transition",b=>{const v=b;yr(v?.source,t)&&v.data?.to&&u(v.data.to)});return()=>{g?.unsubscribe()}},[e,t]),{motion:r,motionRaw:s,detection:i,phase:l}}function rM(e,t,r=5e3){const[n,s]=E([]);Q(()=>{if(t===null)return;let u=!1;const d=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(h=>{u||s(h)}).catch(()=>{})};d();const p=setInterval(d,r);return()=>{u=!0,clearInterval(p)}},[e,t,r]);const[a,i]=E(null);Q(()=>{if(t===null)return;let u=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(d=>{u||!d||i({phase:d.phase,detectionFps:d.actualFps,avgInferenceMs:d.avgInferenceTimeMs,droppedFrames:d.droppedFrames})}).catch(()=>{}),()=>{u=!0}},[e,t]),Fr("pipeline.camera-metrics-snapshot",u=>{if(t===null)return;const d=u.data;d.deviceId!==t||!d.metrics||i({phase:d.metrics.phase,detectionFps:d.metrics.actualFps,avgInferenceMs:d.metrics.avgInferenceTimeMs,droppedFrames:d.metrics.droppedFrames})});const{streams:c,hasWebrtc:l}=q(()=>t===null||n.length===0?{streams:[],hasWebrtc:!1}:{streams:n.map(u=>({id:u.id,label:u.label,target:u.target,status:u.status,inputFps:u.inputFps,decodeFps:u.decodeFps,bitrateKbps:u.bitrateKbps})),hasWebrtc:!0},[t,n]);return{streams:c,hasWebrtc:l,pipelineMetrics:a,createSession:R(async(u,d)=>{if(t===null)throw new Error("No device selected");const p=await e.webrtcSession.createSession.mutate({deviceId:t,target:u,hints:d});return{sessionId:p.sessionId,sdpOffer:p.sdpOffer}},[e,t]),sendAnswer:R(async(u,d)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:u,sdpAnswer:d})},[e,t]),closeSession:R(async u=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:u}).catch(()=>{})},[e,t])}}function nM(e){const t=e?.deviceId??null,r=e?.historyLimit??20,n=Li("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=E([]);return Q(()=>{n&&a(i=>{if(i.length>0&&i[0].deviceId===n.deviceId&&i[0].timestamp===n.timestamp)return i;const c=[n,...i];return c.length>r?c.slice(0,r):c})},[n,r]),{latest:n??null,history:s}}function oM(e){const t=tt(),r=q(()=>e?JSON.stringify(e):"",[e]),[n,s]=E(()=>t.listDevices(e));return Q(()=>{const a=()=>{s(t.listDevices(e))};a();let i=null,c=null;try{i=t.onDeviceAdded(a),c=t.onDeviceRemoved(a)}catch{}const l=t.subscribeConnectionEvents(u=>{u==="connected"&&a()});return()=>{i?.(),c?.(),l()}},[t,e,r]),n}function sM(e){const t=tt(),[r,n]=E(()=>e===null?null:t.getDevice(e));return Q(()=>{if(e===null){n(null);return}const s=()=>{n(t.getDevice(e))};s();let a=null,i=null;try{a=t.onDeviceAdded(s),i=t.onDeviceRemoved(s)}catch{}const c=t.subscribeConnectionEvents(l=>{l==="connected"&&s()});return()=>{a?.(),i?.(),c()}},[t,e]),r}function aM(e,t,r){const n=tt();return Ls({queryKey:e,queryFn:()=>t(n)(),...r})}function iM(e,t){const r=tt();return zl({mutationFn:n=>e(r)(n),...t})}function lM(e,t){const r=tt(),n=or(),[s,a]=E(r.connectionVersion);Q(()=>r.subscribeConnectionEvents((l,u)=>{l==="connected"&&a(u)}),[r]);const i=t.join("|"),c=JSON.stringify(e);Q(()=>{const l=[],u=()=>{const d=JSON.parse(c),p=d.length===1&&Array.isArray(d[0])?d:[d];n.invalidateQueries({queryKey:p})};u();for(const d of i.split("|"))if(d)try{l.push(r.subscribeEvent(d,u))}catch{}return()=>{for(const d of l)d()}},[r,n,i,c,s])}export{I5 as AddonGlobalSettingsForm,uy as AgentStepEditor,Cy as AppShell,F5 as AudioClassificationList,z5 as AudioLevelWaveform,B5 as AudioWaveform,Qh as AutotrackSection,Lv as BTN_COMPACT,$v as BTN_COMPACT_DANGER,Ov as BTN_COMPACT_PRIMARY,Bv as BTN_COMPACT_WARNING,gt as Badge,sm as BatteryBadge,Mi as BottomSheet,ay as Breadcrumb,at as Button,Gv as CHIP_ACTIVE,Fv as CHIP_BASE,Qv as CHIP_INACTIVE,fr as CLASS_COLORS,Wg as CameraStreamPlayer,mi as Card,Vp as Checkbox,Ny as CodeBlock,jp as CollapsibleCard,$g as ConfigFormBuilder,ir as ConfigFormField,so as ConfigSchemaField,q5 as ConfirmActionButton,xy as ConfirmDialogProvider,hb as CopyButton,Fy as CustomFieldRenderersProvider,Iy as DEFAULT_COLOR,of as DataTable,Ty as DetectionCanvas,Fg as DetectionOverlay,Dy as DetectionResultTree,bh as DevShell,V5 as DeviceActivityPanel,My as DeviceCard,Gy as DeviceContextProvider,$5 as DeviceExportPanel,Ey as DeviceGrid,Pn as DeviceItem,Py as DeviceList,Wp as Dialog,yi as DialogContent,Jp as DialogDescription,Yp as DialogFooter,Zp as DialogHeader,Xp as DialogTitle,Vv as DialogTrigger,H5 as DiscoveryPanel,K5 as DoorbellRecentPanel,qv as Dropdown,Kv as DropdownContent,Zv as DropdownItem,Wv as DropdownTrigger,Sf as EmptyState,Mf as ErrorBox,_l as EventStream,Sy as FilterBar,U5 as FloatingEventStream,j5 as FloatingLogStream,sy as FloatingPanel,vy as FormField,Cv as GRID_GAP,Av as GRID_PAIRED,Ev as GRID_QUICK_STATS,Kh as HOST_WIDGETS,zv as INPUT_COMPACT,fi as IconButton,Oy as ImageSelector,$y as InferenceConfigSelector,Mn as Input,Z5 as KebabMenu,ky as KeyValueList,Mv as LIST_ROW,hi as Label,Rl as LogStream,ph as LoginForm,nf as MobileDrawer,Wh as MotionZonesSettings,dg as NodeMultiSelectField,my as NodePicker,ug as NodeSelectField,Co as PHASE_CONFIG,Bh as PTZOverlay,yy as PageHeader,Q5 as PhaseIcon,_y as PipelineBuilder,Ry as PipelineRuntimeSelector,Jr as PipelineStep,dy as PipelineTreeMatrix,P5 as PlayerOverlaysProvider,ef as Popover,rf as PopoverContent,tf as PopoverTrigger,gy as ProviderBadge,Fh as PtzPanel,fb as QrCode,G5 as ResponseLog,Nv as SECTION_BODY,wv as SECTION_CARD,kv as SECTION_HEADER,Pv as SPLIT_PANEL_OUTER,Rv as SPLIT_PANEL_SIDE,Sv as STACK_GAP,Y5 as ScopePicker,_i as ScrollArea,Ir as Select,Nf as SemanticBadge,gi as Separator,Yo as Sidebar,Zo as SidebarItem,Hp as Skeleton,iy as SlideOverPanel,W5 as SnapshotButton,wy as StatCard,Fb as StateValuesStream,hy as StatusBadge,Ly as StepTimings,ly as StepTreeMaster,D5 as StreamBrokerSelector,T5 as StreamPanel,qp as Switch,yf as SystemProvider,Iv as TEXT_FIELD_LABEL,ur as TEXT_HINT,Dv as TEXT_METRIC,_v as TEXT_SECTION_LABEL,Tv as TEXT_VALUE,ty as Tabs,oy as TabsContent,ry as TabsList,ny as TabsTrigger,vo as ThemeProvider,Yv as Tooltip,Jv as TooltipContent,Xv as TooltipTrigger,by as VersionBadge,M5 as WidgetRegistryProvider,Zh as WidgetSlot,J5 as ZoneEditingProvider,cy as buildStepTreeFromSchema,C as cn,ct as createSharedContext,yv as createTheme,Jl as darkColors,ho as defaultTheme,Ay as deriveDeviceKind,$d as ensureMfHostInit,je as getClassColor,ua as getPhaseVisual,Dg as isFieldVisible,ec as lightColors,ml as loadRemoteBundle,jv as mirror,zy as mountAddonPage,Uv as providerIcons,Hv as statusIcons,xv as themeToCss,f as trpc,jy as useAccessoriesGetStatus,Uy as useAddonPagesListPages,k0 as useAddonSettingsGetDeviceSettings,x0 as useAddonSettingsGetGlobalSettings,N0 as useAddonSettingsUpdateDeviceSettings,w0 as useAddonSettingsUpdateGlobalSettings,wh as useAddonWidgetsListWidgets,b0 as useAddonsApplyAutoUpdateToAll,v0 as useAddonsCustom,n0 as useAddonsForceRefresh,h0 as useAddonsGetAddonAutoUpdate,f0 as useAddonsGetAutoUpdateSettings,s0 as useAddonsGetLastRestart,Hy as useAddonsGetLogs,u0 as useAddonsGetVersions,Wy as useAddonsInstallFromWorkspace,qy as useAddonsInstallPackage,Ky as useAddonsIsWorkspaceAvailable,xh as useAddonsList,i0 as useAddonsListCapabilityProviders,a0 as useAddonsListFrameworkPackages,Vy as useAddonsListPackages,e0 as useAddonsListUpdates,Zy as useAddonsListWorkspacePackages,y0 as useAddonsOnAddonLogs,Xy as useAddonsReloadPackages,d0 as useAddonsRestartAddon,o0 as useAddonsRestartServer,p0 as useAddonsRetryLoad,r0 as useAddonsRollbackPackage,Jy as useAddonsSearchAvailable,g0 as useAddonsSetAddonAutoUpdate,m0 as useAddonsSetAutoUpdateSettings,l0 as useAddonsSetCapabilityProviderEnabled,Yy as useAddonsUninstallPackage,c0 as useAddonsUpdateFrameworkPackage,t0 as useAddonsUpdatePackage,R0 as useAlertsDismiss,S0 as useAlertsEmit,E0 as useAlertsGetUnreadCount,M0 as useAlertsList,P0 as useAlertsMarkAllRead,A0 as useAlertsMarkRead,C0 as useAlertsUpdate,A5 as useAllWidgets,D0 as useAudioAnalysisApplyDeviceSettingsPatch,T0 as useAudioAnalysisGetDeviceLiveContribution,I0 as useAudioAnalysisGetDeviceSettingsContribution,_0 as useAudioAnalysisResolveDeviceSettings,L0 as useAudioAnalyzerAnalyseChunk,O0 as useAudioAnalyzerClassify,B0 as useAudioAnalyzerDispose,$0 as useAudioAnalyzerIsReady,z0 as useAudioAnalyzerReprobeAudioEngine,G0 as useAudioCodecCanHandle,U0 as useAudioCodecCloseSession,Q0 as useAudioCodecCreateDecodeSession,j0 as useAudioCodecCreateEncodeSession,K0 as useAudioCodecFlushEncode,Z0 as useAudioCodecListActiveSessions,F0 as useAudioCodecListSupportedCodecs,W0 as useAudioCodecPullEncoded,V0 as useAudioCodecPullPcm,H0 as useAudioCodecPushEncodedFrame,q0 as useAudioCodecPushPcm,Y0 as useAudioMetricsGetCurrentSnapshot,X0 as useAudioMetricsGetHistory,sx as useBackupDelete,nx as useBackupGetEntries,tx as useBackupList,ax as useBackupListArchives,J0 as useBackupListDestinations,rx as useBackupListLocations,lx as useBackupPreviewSchedule,ox as useBackupRestore,ex as useBackupTrigger,ix as useBackupUpsertDestinationPolicy,cx as useBatteryGetStatus,dx as useBrightnessGetStatus,ux as useBrightnessSetBrightness,px as useCameraCredentialsGetCredentials,fx as useCameraCredentialsGetStatus,hx as useCameraStreamsGetBrokerStreams,mx as useCameraStreamsGetCameraStreams,kh as useCameraStreamsGetRtspEntries,io as useClusterNodes,Gr as useConfirm,vh as useCustomFieldRenderer,cm as useDebouncedString,vx as useDecoderCreateSession,yx as useDecoderDestroySession,Sx as useDecoderGetFrame,bx as useDecoderGetInfo,Cx as useDecoderGetShmStats,Ex as useDecoderGetStats,Ax as useDecoderListActiveSessions,wx as useDecoderOpenStream,kx as useDecoderPullFrames,Nx as useDecoderPullHandles,xx as useDecoderPushPacket,Px as useDecoderReprobeHwaccel,gx as useDecoderSupportsCodec,Mx as useDecoderUpdateConfig,Ix as useDetectionPipelineApplyDeviceSettingsPatch,_x as useDetectionPipelineGetDeviceLiveContribution,Rx as useDetectionPipelineGetDeviceSettingsContribution,By as useDevShell,sM as useDevice,Gh as useDeviceAutotrack,tm as useDeviceBattery,ar as useDeviceCapability,tM as useDeviceDetections,Lx as useDeviceDiscoveryAdoptDevice,$x as useDeviceDiscoveryGetStatus,Tx as useDeviceDiscoveryListDiscovered,Dx as useDeviceDiscoveryRefreshDiscovery,Ox as useDeviceDiscoveryReleaseDevice,Qx as useDeviceExportApplyDeviceSettingsPatch,zx as useDeviceExportExposeDevice,Gx as useDeviceExportGetDeviceLiveContribution,Fx as useDeviceExportGetDeviceSettingsContribution,Nh as useDeviceExportGetStatus,Sh as useDeviceExportListExposedDevices,Bx as useDeviceExportListSupportedDeviceKinds,Ch as useDeviceExportUnexposeDevice,yh as useDeviceId,e1 as useDeviceManagerAddLocation,E1 as useDeviceManagerAdoptDevice,jx as useDeviceManagerAllocateDeviceId,P1 as useDeviceManagerCreateDevice,d1 as useDeviceManagerDisable,M1 as useDeviceManagerDiscoverDevices,u1 as useDeviceManagerEnable,b1 as useDeviceManagerGetAllBindings,g1 as useDeviceManagerGetBindings,s1 as useDeviceManagerGetChildren,i1 as useDeviceManagerGetConfigSchema,A1 as useDeviceManagerGetCreationSchema,o1 as useDeviceManagerGetDevice,N1 as useDeviceManagerGetDeviceAggregate,k1 as useDeviceManagerGetDeviceLiveInfoAggregate,w1 as useDeviceManagerGetDeviceSettingsAggregate,I1 as useDeviceManagerGetDeviceStatusAggregate,l1 as useDeviceManagerGetSettingsSchema,f1 as useDeviceManagerGetStreamProfileMap,a1 as useDeviceManagerGetStreamSources,Mh as useDeviceManagerListAll,x1 as useDeviceManagerListBindableCapsForDeviceType,Jx as useDeviceManagerListLocations,n1 as useDeviceManagerListPersistedByAddon,y1 as useDeviceManagerListWrappersForCap,qx as useDeviceManagerLoadConfig,Kx as useDeviceManagerLoadMeta,Wx as useDeviceManagerLoadRuntimeState,Vx as useDeviceManagerPersistConfig,h1 as useDeviceManagerProbeStreams,Ux as useDeviceManagerRegisterDevice,p1 as useDeviceManagerRemove,Hx as useDeviceManagerRemoveDevice,t1 as useDeviceManagerRemoveLocation,r1 as useDeviceManagerSetDisabled,Yx as useDeviceManagerSetLocation,Xx as useDeviceManagerSetMetadata,Zx as useDeviceManagerSetName,m1 as useDeviceManagerSetStreamProfileMap,v1 as useDeviceManagerSetWrapperActive,R1 as useDeviceManagerTestCreationField,_1 as useDeviceManagerTestField,c1 as useDeviceManagerUpdateConfig,S1 as useDeviceManagerUpdateDeviceField,C1 as useDeviceManagerUpdateDeviceFieldsBatch,D1 as useDeviceOpsGetConfigEntries,$1 as useDeviceOpsGetSettingsSchema,T1 as useDeviceOpsGetStreamSources,O1 as useDeviceOpsRemoveDevice,L1 as useDeviceOpsSetConfig,U1 as useDeviceProviderAdoptDiscoveredDevice,q1 as useDeviceProviderCreateDevice,j1 as useDeviceProviderDiscoverDevices,V1 as useDeviceProviderGetChildCreationSchema,G1 as useDeviceProviderGetDevices,F1 as useDeviceProviderGetStatus,B1 as useDeviceProviderStart,z1 as useDeviceProviderStop,Q1 as useDeviceProviderSupportsDiscovery,H1 as useDeviceProviderSupportsManualCreation,W1 as useDeviceProviderTestCreationField,Gt as useDeviceProxy,Qy as useDeviceSnapshot,rm as useDeviceSnapshotImage,Pf as useDeviceState,Y1 as useDeviceStateGetAllSnapshots,Z1 as useDeviceStateGetCapSlice,K1 as useDeviceStateGetSnapshot,X1 as useDeviceStateSetCapSlice,$i as useDeviceStateSlice,J1 as useDeviceStatusGetStatus,rM as useDeviceWebrtc,oM as useDevices,nM as useDoorbellEvents,ew as useDoorbellGetStatus,lM as useEventInvalidation,Li as useEventStreamLatest,fy as useEventStreamMap,nw as useEventsGetEventClipUrl,rw as useEventsGetEventThumbnail,tw as useEventsGetEvents,ow as useFeatureProbeGetStatus,lw as useIntegrationsCreate,uw as useIntegrationsDelete,aw as useIntegrationsGet,fw as useIntegrationsGetAvailableTypes,iw as useIntegrationsGetByAddonId,dw as useIntegrationsGetSettings,sw as useIntegrationsList,pw as useIntegrationsSetSettings,mw as useIntegrationsTestConnection,cw as useIntegrationsUpdate,xw as useIntercomEndTalkSession,ww as useIntercomGetStatus,gw as useIntercomHandleAnswer,yw as useIntercomPushTalkPcm,hw as useIntercomStartSession,vw as useIntercomStartTalkSession,bw as useIntercomStopSession,ey as useIsMidWidth,zr as useIsMobile,Wt as useLiveBuffer,Fr as useLiveEvent,Cw as useLocalNetworkGetAllowedAddresses,Sw as useLocalNetworkGetConnectionEndpoints,Nw as useLocalNetworkGetPreferred,kw as useLocalNetworkList,Ew as useLocalNetworkResetAllowlistToBestMatch,Mw as useLocalNetworkSetAllowedAddresses,Aw as useMeshNetworkGetStatus,Pw as useMeshNetworkJoin,_w as useMeshNetworkLeave,Tw as useMeshNetworkListPeers,Iw as useMeshNetworkLogout,Rw as useMeshNetworkStartLogin,Dw as useMeshNetworkTestConnection,Lw as useMetricsProviderCollectSnapshot,jw as useMetricsProviderGetAddonStats,Ow as useMetricsProviderGetCached,Fw as useMetricsProviderGetCpuTemperature,$w as useMetricsProviderGetCurrent,Bw as useMetricsProviderGetDiskSpace,zw as useMetricsProviderGetGpuInfo,Gw as useMetricsProviderGetProcessStats,Hw as useMetricsProviderKillProcess,Qw as useMetricsProviderListAddonInstances,Uw as useMetricsProviderListNodeProcesses,Ww as useMotionDetectionAnalyze,Jw as useMotionDetectionApplyDeviceSettingsPatch,Xw as useMotionDetectionGetDeviceLiveContribution,Yw as useMotionDetectionGetDeviceSettingsContribution,Kw as useMotionDetectionRemoveCamera,Zw as useMotionDetectionReset,qw as useMotionGetStatus,Vw as useMotionIsDetected,t2 as useMotionTriggerGetStatus,e2 as useMotionTriggerSetMotionTrigger,r2 as useMotionZonesGetOptions,o2 as useMotionZonesGetStatus,n2 as useMotionZonesSetZone,i2 as useMqttBrokerAddBroker,a2 as useMqttBrokerGetBrokerConfig,p2 as useMqttBrokerGetStatus,s2 as useMqttBrokerListBrokers,l2 as useMqttBrokerRemoveBroker,u2 as useMqttBrokerStartEmbeddedBroker,d2 as useMqttBrokerStopEmbeddedBroker,c2 as useMqttBrokerTestConnection,f2 as useNativeObjectDetectionGetStatus,g2 as useNetworkAccessGetEndpoint,b2 as useNetworkAccessGetStatus,v2 as useNetworkAccessListEndpoints,m2 as useNetworkAccessStart,h2 as useNetworkAccessStop,x2 as useNetworkQualityGetAllStats,y2 as useNetworkQualityGetDeviceStats,w2 as useNetworkQualityReportClientStats,R2 as useNodesClusterAddonStatus,N2 as useNodesDeployAddon,D2 as useNodesExecuteQuery,_2 as useNodesGetCapUsageGraph,I2 as useNodesGetNodeAddons,P2 as useNodesRenameNode,C2 as useNodesRestartAddon,E2 as useNodesRestartNode,M2 as useNodesRestartProcess,T2 as useNodesSetProcessLogLevel,A2 as useNodesShutdownNode,k2 as useNodesTopology,S2 as useNodesUndeployAddon,L2 as useNotificationOutputSend,O2 as useNotificationOutputSendTest,py as useOptionalSystem,hl as useOptionalWidgetRegistry,B2 as useOsdGetStatus,$2 as useOsdSetOverlay,$h as usePTZ,Z2 as usePipelineAnalyticsApplyDeviceSettingsPatch,Q2 as usePipelineAnalyticsClearTracks,z2 as usePipelineAnalyticsGetActiveTracks,H2 as usePipelineAnalyticsGetAudioEvents,K2 as usePipelineAnalyticsGetDeviceLiveContribution,W2 as usePipelineAnalyticsGetDeviceSettingsContribution,V2 as usePipelineAnalyticsGetEventMedia,j2 as usePipelineAnalyticsGetMotionEvents,U2 as usePipelineAnalyticsGetObjectEvents,F2 as usePipelineAnalyticsGetTrack,q2 as usePipelineAnalyticsGetTrackMedia,G2 as usePipelineAnalyticsListTracks,vk as usePipelineExecutorCacheFrameInPool,mk as usePipelineExecutorDeleteModel,uk as usePipelineExecutorDeleteTemplate,hk as usePipelineExecutorDetect,fk as usePipelineExecutorDownloadModel,pk as usePipelineExecutorGetAddonModels,Pk as usePipelineExecutorGetAudioCapabilities,Y2 as usePipelineExecutorGetAvailableEngines,dk as usePipelineExecutorGetCapabilities,J2 as usePipelineExecutorGetDefaultSteps,_k as usePipelineExecutorGetDetectionConfigSchema,wk as usePipelineExecutorGetEffectiveTuning,sk as usePipelineExecutorGetGlobalPipelineConfig,ok as usePipelineExecutorGetGlobalSteps,ak as usePipelineExecutorGetOrchestratorConfigSchema,Ak as usePipelineExecutorGetReferenceAudio,Ek as usePipelineExecutorGetReferenceAudioFiles,Mk as usePipelineExecutorGetReferenceImage,nk as usePipelineExecutorGetSchema,X2 as usePipelineExecutorGetSelectedEngine,tk as usePipelineExecutorGetVideoPipelineSteps,yk as usePipelineExecutorInferCached,Sk as usePipelineExecutorKillEngine,kk as usePipelineExecutorListLoadedEngines,Ck as usePipelineExecutorListReferenceImages,ik as usePipelineExecutorListTemplates,ek as usePipelineExecutorReprobeEngine,Rk as usePipelineExecutorRunAudioTest,gk as usePipelineExecutorRunPipeline,bk as usePipelineExecutorRunPipelineBatch,lk as usePipelineExecutorSaveTemplate,rk as usePipelineExecutorSetVideoPipelineSteps,Nk as usePipelineExecutorSpinEngine,xk as usePipelineExecutorUncacheFrame,ck as usePipelineExecutorUpdateTemplate,fN as usePipelineOrchestratorApplyDeviceSettingsPatch,Hk as usePipelineOrchestratorAssignAudio,Qk as usePipelineOrchestratorAssignDecoder,Ik as usePipelineOrchestratorAssignPipeline,uN as usePipelineOrchestratorDeleteTemplate,$k as usePipelineOrchestratorGetAgentLoad,Yk as usePipelineOrchestratorGetAgentSettings,qk as usePipelineOrchestratorGetAudioAssignment,Kk as usePipelineOrchestratorGetAudioAssignments,Wk as usePipelineOrchestratorGetAudioNodeLoad,zk as usePipelineOrchestratorGetCameraMetrics,tN as usePipelineOrchestratorGetCameraSettings,nN as usePipelineOrchestratorGetCameraStepOverrides,Fk as usePipelineOrchestratorGetCapabilityBindings,Zk as usePipelineOrchestratorGetDecoderAssignment,Uk as usePipelineOrchestratorGetDecoderAssignments,pN as usePipelineOrchestratorGetDeviceLiveContribution,dN as usePipelineOrchestratorGetDeviceSettingsContribution,Bk as usePipelineOrchestratorGetGlobalMetrics,Ok as usePipelineOrchestratorGetPipelineAssignment,Lk as usePipelineOrchestratorGetPipelineAssignments,Xk as usePipelineOrchestratorListAgentSettings,iN as usePipelineOrchestratorListTemplates,Dk as usePipelineOrchestratorRebalance,eN as usePipelineOrchestratorRemoveAgentSettings,aN as usePipelineOrchestratorResolvePipeline,lN as usePipelineOrchestratorSaveTemplate,Jk as usePipelineOrchestratorSetAgentAddonDefaults,sN as usePipelineOrchestratorSetCameraPipelineForAgent,oN as usePipelineOrchestratorSetCameraStepOverride,rN as usePipelineOrchestratorSetCameraStepToggle,Gk as usePipelineOrchestratorSetCapabilityBinding,Vk as usePipelineOrchestratorUnassignAudio,jk as usePipelineOrchestratorUnassignDecoder,Tk as usePipelineOrchestratorUnassignPipeline,cN as usePipelineOrchestratorUpdateTemplate,mN as usePipelineRunnerAttachCamera,hN as usePipelineRunnerDetachCamera,xN as usePipelineRunnerGetAllCameraMetrics,yN as usePipelineRunnerGetCameraMetrics,wN as usePipelineRunnerGetLocalCameras,bN as usePipelineRunnerGetLocalLoad,vN as usePipelineRunnerGetLocalMetrics,gN as usePipelineRunnerReportMotion,kN as usePlatformProbeGetCapabilities,NN as usePlatformProbeGetHardware,MN as usePlatformProbeGetHardwareEncoders,EN as usePlatformProbeRefreshHardwareEncoders,CN as usePlatformProbeResolveHwAccel,SN as usePlatformProbeResolveInferenceConfig,Uh as usePlayerOverlayLayer,R5 as usePlayerOverlayLayers,_5 as usePlayerToolbarButton,jh as usePlayerToolbarButtons,FN as usePtzAutotrackGetSettings,Eh as usePtzAutotrackGetStatus,Ah as usePtzAutotrackSetEnabled,Ph as usePtzAutotrackSetSettings,PN as usePtzContinuousMove,DN as usePtzDeletePreset,LN as usePtzGetOptions,$N as usePtzGetPosition,_N as usePtzGetPresets,zN as usePtzGetStatus,ON as usePtzGoHome,IN as usePtzGoToPreset,AN as usePtzMove,TN as usePtzSavePreset,BN as usePtzSetAutofocus,RN as usePtzStop,GN as useRebootReboot,qN as useRecordingEngineDisable,VN as useRecordingEngineEnable,tS as useRecordingEngineEstimateGlobalStorage,eS as useRecordingEngineEstimateStorage,JN as useRecordingEngineGetAvailability,WN as useRecordingEngineGetConfig,lS as useRecordingEngineGetMotionStats,ZN as useRecordingEngineGetPlaylist,oS as useRecordingEngineGetPolicy,sS as useRecordingEngineGetPolicyStatus,aS as useRecordingEngineGetRetentionConfig,XN as useRecordingEngineGetSegments,HN as useRecordingEngineGetStatus,rS as useRecordingEngineGetStorageUsage,YN as useRecordingEngineGetThumbnail,nS as useRecordingEngineSetPolicy,KN as useRecordingEngineUpdateConfig,iS as useRecordingEngineUpdateRetentionConfig,jN as useRecordingGetPlaybackUrl,QN as useRecordingGetSegments,UN as useRecordingGetThumbnailAt,Lh as useRemoteComponent,hS as useSettingsStoreCount,bS as useSettingsStoreDeclareCollection,mS as useSettingsStoreDelete,cS as useSettingsStoreGet,pS as useSettingsStoreInsert,gS as useSettingsStoreIsEmpty,dS as useSettingsStoreQuery,uS as useSettingsStoreSet,fS as useSettingsStoreUpdate,NS as useSnapshotApplyDeviceSettingsPatch,kS as useSnapshotGetDeviceLiveContribution,wS as useSnapshotGetDeviceSettingsContribution,vS as useSnapshotGetSnapshot,xS as useSnapshotGetStatus,yS as useSnapshotInvalidateCache,CS as useSnapshotProviderGetSnapshot,SS as useSnapshotProviderSupportsDevice,OS as useStorageAbortUpload,$S as useStorageBeginDownload,TS as useStorageBeginUpload,_S as useStorageDelete,jS as useStorageDeleteLocation,zS as useStorageEndDownload,PS as useStorageExists,LS as useStorageFinalizeUpload,IS as useStorageGetAvailableSpace,GS as useStorageGetDefaultLocation,RS as useStorageList,FS as useStorageListLocations,HS as useStorageListProviders,AS as useStorageRead,BS as useStorageReadChunk,MS as useStorageResolve,VS as useStorageTestConfig,US as useStorageTestLocation,QS as useStorageUpsertLocation,ES as useStorageWrite,DS as useStorageWriteChunk,kC as useStreamBrokerApplyDeviceSettingsPatch,KS as useStreamBrokerAssignProfile,hC as useStreamBrokerGetAllRtspEntries,JS as useStreamBrokerGetBrokerStats,wC as useStreamBrokerGetDeviceLiveContribution,xC as useStreamBrokerGetDeviceSettingsContribution,fC as useStreamBrokerGetPreBufferInfo,gC as useStreamBrokerGetRtspEntry,mC as useStreamBrokerGetRtspPort,nC as useStreamBrokerGetStreamUrl,oC as useStreamBrokerGetStreamWithCodec,yC as useStreamBrokerIsRtspEnabled,tC as useStreamBrokerKillClient,YS as useStreamBrokerListAllCameraStreams,XS as useStreamBrokerListAllProfileSlots,eC as useStreamBrokerListClients,qS as useStreamBrokerPublishCameraStream,iC as useStreamBrokerPullAudioChunks,uC as useStreamBrokerPullFrameHandles,bC as useStreamBrokerRegenerateRtspToken,sC as useStreamBrokerReleaseStreamWithCodec,rC as useStreamBrokerRestartProfile,WS as useStreamBrokerRetractCameraStream,pC as useStreamBrokerSetPreBufferDuration,vC as useStreamBrokerSetRtspEnabled,aC as useStreamBrokerSubscribeAudioChunks,cC as useStreamBrokerSubscribeFrames,ZS as useStreamBrokerUnassignProfile,lC as useStreamBrokerUnsubscribeAudioChunks,dC as useStreamBrokerUnsubscribeFrames,CC as useStreamParamsGetConfigSchema,NC as useStreamParamsGetOptions,MC as useStreamParamsGetStatus,SC as useStreamParamsSetProfile,AC as useSwitchGetStatus,EC as useSwitchSetState,tt as useSystem,_C as useSystemFeatureFlags,LC as useSystemForceRetentionCleanup,TC as useSystemGetRetentionConfig,RC as useSystemHealth,PC as useSystemInfo,iM as useSystemMutation,IC as useSystemNetworkAddresses,aM as useSystemQuery,DC as useSystemSetRetentionConfig,ac as useThemeMode,OC as useToastOnToast,$C as useTurnProviderGetTurnServers,e5 as useUserManagementConfirmTotp,VC as useUserManagementCreateApiKey,KC as useUserManagementCreateScopedToken,zC as useUserManagementCreateUser,GC as useUserManagementDeleteUser,t5 as useUserManagementDisableTotp,r5 as useUserManagementGetTotpStatus,HC as useUserManagementListApiKeys,l5 as useUserManagementListOauthSessions,XC as useUserManagementListScopedTokens,BC as useUserManagementListUsers,s5 as useUserManagementOauthExchangeCode,o5 as useUserManagementOauthIssueCode,a5 as useUserManagementOauthRefresh,i5 as useUserManagementOauthVerifyAccessToken,QC as useUserManagementResetPassword,qC as useUserManagementRevokeApiKey,c5 as useUserManagementRevokeOauthSession,ZC as useUserManagementRevokeScopedToken,jC as useUserManagementSetUserScopes,JC as useUserManagementSetupTotp,FC as useUserManagementUpdateUser,WC as useUserManagementValidateApiKey,UC as useUserManagementValidateCredentials,YC as useUserManagementValidateScopedToken,n5 as useUserManagementVerifyTotp,m5 as useWebrtcSessionCloseSession,d5 as useWebrtcSessionCreateSession,f5 as useWebrtcSessionHandleAnswer,p5 as useWebrtcSessionHandleOffer,h5 as useWebrtcSessionHasAdaptiveBitrate,u5 as useWebrtcSessionListStreams,E5 as useWidget,Dh as useWidgetMetadata,uo as useWidgetRegistry,v5 as useZoneAnalyticsGetCameraHistory,g5 as useZoneAnalyticsGetCurrentSnapshot,y5 as useZoneAnalyticsGetUnzonedHistory,b5 as useZoneAnalyticsGetZoneHistory,eM as useZoneEditing,x5 as useZoneRulesListRules,w5 as useZoneRulesSetRules,N5 as useZonesAddZone,k5 as useZonesListZones,S5 as useZonesRemoveZone,C5 as useZonesUpdateZone,X5 as validateScopes};
|