@camstack/addon-admin-ui 0.1.40 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-Cv6qLu_-.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CRKSbdgN.js} +1 -1
  2. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-CChEG9e0.js → __mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-BGPfTw3V.js} +1 -1
  3. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-C1BmHlGM.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-jPpiOa0I.js} +1 -1
  4. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-Bxv_3KWz.js → __mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs_commonjs-proxy-DYNYuSL7.js} +1 -1
  5. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-DC63qZbr.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-ij0ODm-n.js} +1 -1
  6. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-D2C49VyZ.js → __mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-C4Ko8zXp.js} +1 -1
  7. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-D3WbXy3O.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-Cf5gSqc_.js} +1 -1
  8. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Csg6EbPB.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-CYaX3FDr.js} +1 -1
  9. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-CUc0oFNo.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-rHwdrynu.js} +1 -1
  10. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-vh0hhA5d.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs_commonjs-proxy-DRDS6j-Y.js} +1 -1
  11. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-CpGtTxci.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-cUuqcEcL.js} +2 -2
  12. package/dist/assets/{__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs_commonjs-proxy-RUDPE9aM.js → __mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs_commonjs-proxy-CzMP41OH.js} +1 -1
  13. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-yD7UmaAo.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DNAkeUTZ.js} +1 -1
  14. package/dist/assets/{devices-a77yscD5.js → devices-DaqavVOg.js} +1 -1
  15. package/dist/assets/{hostInit-DaDF_bfJ.js → hostInit-ByQycOVJ.js} +1 -1
  16. package/dist/assets/index-B6kubsZI.js +151 -0
  17. package/dist/assets/index-BI1a6Whs.js +1 -0
  18. package/dist/assets/index-BVNg3Krt.js +1185 -0
  19. package/dist/assets/{index-DsOnjZM4.js → index-BbwPCEeT.js} +1 -1
  20. package/dist/assets/{index-CehI0ALS.js → index-BpC2rqYA.js} +1 -1
  21. package/dist/assets/index-CukoHCyD.js +1 -0
  22. package/dist/assets/{index-DVUREV1A.js → index-Cyva9RmE.js} +1 -1
  23. package/dist/assets/index-DLnW8nGB.css +1 -0
  24. package/dist/assets/index-DNydUTOB.js +1 -0
  25. package/dist/assets/{index-IsVfuhTX.js → index-DVLRgczW.js} +1 -1
  26. package/dist/assets/index-PXbclFuZ.js +87 -0
  27. package/dist/assets/index-QqQmcu5i.js +1 -0
  28. package/dist/assets/method-access-map-DjDdPRYC.js +1 -0
  29. package/dist/assets/{remoteEntry-VsZWB5do.js → remoteEntry-iRKuVHUX.js} +1 -1
  30. package/dist/assets/{schemas-BEt-CulV.js → schemas-BdJePqbR.js} +5 -5
  31. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-VQvlRqZ-.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-QVZxTxLo.js} +2 -2
  32. package/dist/index.html +152 -9
  33. package/dist/mf-entry-bootstrap-0.js +2 -2
  34. package/dist/server/addon.js +413 -44
  35. package/dist/server/addon.js.map +1 -1
  36. package/dist/sw.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/assets/index-C8NE-4Ma.js +0 -1
  39. package/dist/assets/index-COoei6lw.css +0 -1
  40. package/dist/assets/index-D4yaxCPF.js +0 -87
  41. package/dist/assets/index-DAMgd5aW.js +0 -1
  42. package/dist/assets/index-DAenO2kJ.js +0 -151
  43. package/dist/assets/index-DWdPkQ_j.js +0 -1
  44. package/dist/assets/index-Dj1ZxUR8.js +0 -1150
  45. package/dist/assets/index-EjW6hqu2.js +0 -1
  46. package/dist/assets/method-access-map-BgqTQNPE.js +0 -1
  47. package/dist/registerSW.js +0 -1
@@ -0,0 +1,87 @@
1
+ import{e as M,h as I,c as Z,f as X,d as Pe,b as st,i as J,n as De,R as Ce,m as Ct,o as Mc,p as Ec,k as ur,g as xo,a as la}from"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs-ij0ODm-n.js";import{c as o,d as m,e as ve,a as ca}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-C_6K4VBY.js";import{b as yr,a as ua}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs-Cf5gSqc_.js";import{b as Ac,a as da}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.mjs-rHwdrynu.js";import{n as xr,m as pa,h as Pc,o as Rc,p as _c,_ as fa}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-CRKSbdgN.js";import{c as ma,s as ha,B as Ic,F as Tc,n as Dc,_ as ga}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.mjs-DIkg6-MH.js";import{a as Lc,_ as ba}from"./__mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.mjs-jPpiOa0I.js";import{a as xt,b as Oc,c as mn,d as jt,e as qr,_ as va,f as ya,g as xa,h as $c}from"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.mjs-cUuqcEcL.js";import{_ as wa}from"./__mfe_internal__admin_ui_host__loadShare__konva__loadShare__.mjs-g85Oidc0.js";import{D as Bc,c as Fc,E as zc}from"./index-BI1a6Whs.js";import{K as Gc,E as ce,A as Qc}from"./method-access-map-DjDdPRYC.js";import{c as jc}from"./devices-DaqavVOg.js";import{a as wo,o as Uc,b as hn,s as wt,n as Wo}from"./schemas-BdJePqbR.js";import"./__mfe_internal__admin_ui_host__loadShare__react__loadShare__.mjs_commonjs-proxy-C4Ko8zXp.js";import"./__mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-CYaX3FDr.js";var ka={frigate:"#3b82f6",scrypted:"#a855f7",reolink:"#06b6d4",homeAssistant:"#22d3ee",rtsp:"#78716c"},Hc={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:ka},Vc={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:ka},qo={colors:{dark:Hc,light:Vc},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 Na(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]=Na(a,s):s!==void 0&&(r[n]=s)}return r}function jy(e){return e?Na(structuredClone(qo),e):structuredClone(qo)}function Sa(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Wc(e){return`--color-${Sa(e)}`}function Ko(e){const t=[];for(const[r,n]of Object.entries(e))r!=="provider"&&t.push(` ${Wc(r)}: ${n};`);return t.join(`
2
+ `)}function qc(e){const t=[];for(const[r,n]of Object.entries(e))t.push(` --color-provider-${Sa(r)}: ${n};`);return t.join(`
3
+ `)}function Kc(e){const t=[];for(const[r,n]of Object.entries(e))t.push(` --spacing-${r}: ${n}px;`);return t.join(`
4
+ `)}function Zc(e){const t=[];for(const[r,n]of Object.entries(e))t.push(` --radius-${r}: ${n}px;`);return t.join(`
5
+ `)}function Uy(e){const t=Ko(e.colors.dark),r=Ko(e.colors.light);return`@theme {
6
+ ${qc(e.colors.dark.provider)}
7
+ ${Kc(e.spacing)}
8
+ ${Zc(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 Ca=st(null),gn=["dark","light","system"];function Ma(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Yc(e,t){if(typeof window>"u")return t;const r=localStorage.getItem(e);return r==="dark"||r==="light"||r==="system"?r:t}function Zo(e){return e==="system"?Ma():e}function Yo({children:e,defaultMode:t="system",storageKey:r="camstack-theme-mode"}){const[n,s]=M(()=>Yc(r,t)),[a,i]=M(()=>Zo(n)),c=I(d=>{s(d),i(Zo(d)),typeof window<"u"&&localStorage.setItem(r,d)},[r]),l=I(()=>{c(gn[(gn.indexOf(n)+1)%gn.length]??"dark")},[n,c]);Z(()=>{if(typeof document>"u")return;const d=document.documentElement;d.classList.remove("dark","light"),d.classList.add(a)},[n,a]),Z(()=>{if(typeof window>"u"||n!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),p=()=>{i(Ma())};return d.addEventListener("change",p),()=>d.removeEventListener("change",p)},[n]);const u=X(()=>({mode:n,resolvedMode:a,setMode:c,toggleMode:l}),[n,a,c,l]);return o(Ca.Provider,{value:u,children:e})}function Xc(){const e=Pe(Ca);if(!e)throw new Error("useThemeMode must be used within a ThemeProvider");return e}var bn={};function Ea(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=Ea(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function Aa(){for(var e,t,r=0,n="",s=arguments.length;r<s;r++)(e=arguments[r])&&(t=Ea(e))&&(n&&(n+=" "),n+=t);return n}var Jc=(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},eu=(e,t)=>({classGroupId:e,validator:t}),Pa=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Kr="-",Xo=[],tu="arbitrary..",ru=e=>{const t=ou(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return nu(i);const c=i.split(Kr);return Ra(c,c[0]===""&&c.length>1?1:0,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=n[i],u=r[i];return l?u?Jc(u,l):l:u||Xo}return r[i]||Xo}}},Ra=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],s=r.nextPart.get(n);if(s){const l=Ra(e,t+1,s);if(l)return l}const a=r.validators;if(a===null)return;const i=t===0?e.join(Kr):e.slice(t).join(Kr),c=a.length;for(let l=0;l<c;l++){const u=a[l];if(u.validator(i))return u.classGroupId}},nu=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?tu+n:void 0})(),ou=e=>{const{theme:t,classGroups:r}=e;return su(r,t)},su=(e,t)=>{const r=Pa();for(const n in e){const s=e[n];ko(s,r,n,t)}return r},ko=(e,t,r,n)=>{const s=e.length;for(let a=0;a<s;a++){const i=e[a];au(i,t,r,n)}},au=(e,t,r,n)=>{if(typeof e=="string"){iu(e,t,r);return}if(typeof e=="function"){lu(e,t,r,n);return}cu(e,t,r,n)},iu=(e,t,r)=>{const n=e===""?t:_a(t,e);n.classGroupId=r},lu=(e,t,r,n)=>{if(uu(e)){ko(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(eu(r,e))},cu=(e,t,r,n)=>{const s=Object.entries(e),a=s.length;for(let i=0;i<a;i++){const[c,l]=s[i];ko(l,_a(t,c),r,n)}},_a=(e,t)=>{let r=e;const n=t.split(Kr),s=n.length;for(let a=0;a<s;a++){const i=n[a];let c=r.nextPart.get(i);c||(c=Pa(),r.nextPart.set(i,c)),r=c}return r},uu=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,du=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)}}},Qn="!",Jo=":",pu=[],es=(e,t,r,n,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:s}),fu=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===Jo){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(Qn)?(h=p.slice(0,-1),g=!0):p.startsWith(Qn)&&(h=p.slice(1),g=!0);const b=u&&u>l?u-l:void 0;return es(a,g,h,b)};if(t){const s=t+Jo,a=n;n=i=>i.startsWith(s)?a(i.slice(s.length)):es(pu,!1,i,void 0,!0)}if(r){const s=n;n=a=>r({className:a,parseClassName:s})}return n},mu=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}},hu=e=>({cache:du(e.cacheSize),parseClassName:fu(e),sortModifiers:mu(e),...ru(e)}),gu=/\s+/,bu=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:a}=t,i=[],c=e.trim().split(gu);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 w=h.length===0?"":h.length===1?h[0]:a(h).join(":"),k=g?w+Qn:w,S=k+x;if(i.indexOf(S)>-1)continue;i.push(S);const N=s(x,y);for(let E=0;E<N.length;++E){const D=N[E];i.push(k+D)}l=d+(l.length>0?" "+l:l)}return l},vu=(...e)=>{let t=0,r,n,s="";for(;t<e.length;)(r=e[t++])&&(n=Ia(r))&&(s&&(s+=" "),s+=n);return s},Ia=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=Ia(e[n]))&&(r&&(r+=" "),r+=t);return r},yu=(e,...t)=>{let r,n,s,a;const i=l=>(r=hu(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=bu(l,r);return s(l,d),d};return a=i,(...l)=>a(vu(...l))},xu=[],Ae=e=>{const t=r=>r[e]||xu;return t.isThemeGetter=!0,t},Ta=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Da=/^\((?:(\w[\w-]*):)?(.+)\)$/i,wu=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ku=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Nu=/\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$/,Su=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Cu=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Mu=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,lt=e=>wu.test(e),me=e=>!!e&&!Number.isNaN(Number(e)),ct=e=>!!e&&Number.isInteger(Number(e)),vn=e=>e.endsWith("%")&&me(e.slice(0,-1)),nt=e=>ku.test(e),La=()=>!0,Eu=e=>Nu.test(e)&&!Su.test(e),No=()=>!1,Au=e=>Cu.test(e),Pu=e=>Mu.test(e),Ru=e=>!ne(e)&&!oe(e),_u=e=>mt(e,Ba,No),ne=e=>Ta.test(e),yt=e=>mt(e,Fa,Eu),ts=e=>mt(e,Fu,me),Iu=e=>mt(e,Ga,La),Tu=e=>mt(e,za,No),rs=e=>mt(e,Oa,No),Du=e=>mt(e,$a,Pu),Nr=e=>mt(e,Qa,Au),oe=e=>Da.test(e),er=e=>Et(e,Fa),Lu=e=>Et(e,za),ns=e=>Et(e,Oa),Ou=e=>Et(e,Ba),$u=e=>Et(e,$a),Sr=e=>Et(e,Qa,!0),Bu=e=>Et(e,Ga,!0),mt=(e,t,r)=>{const n=Ta.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Et=(e,t,r=!1)=>{const n=Da.exec(e);return n?n[1]?t(n[1]):r:!1},Oa=e=>e==="position"||e==="percentage",$a=e=>e==="image"||e==="url",Ba=e=>e==="length"||e==="size"||e==="bg-size",Fa=e=>e==="length",Fu=e=>e==="number",za=e=>e==="family-name",Ga=e=>e==="number"||e==="weight",Qa=e=>e==="shadow",zu=()=>{const e=Ae("color"),t=Ae("font"),r=Ae("text"),n=Ae("font-weight"),s=Ae("tracking"),a=Ae("leading"),i=Ae("breakpoint"),c=Ae("container"),l=Ae("spacing"),u=Ae("radius"),d=Ae("shadow"),p=Ae("inset-shadow"),h=Ae("text-shadow"),g=Ae("drop-shadow"),b=Ae("blur"),v=Ae("perspective"),y=Ae("aspect"),x=Ae("ease"),w=Ae("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],S=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],N=()=>[...S(),oe,ne],E=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],C=()=>[oe,ne,l],_=()=>[lt,"full","auto",...C()],O=()=>[ct,"none","subgrid",oe,ne],ae=()=>["auto",{span:["full",ct,oe,ne]},ct,oe,ne],de=()=>[ct,"auto",oe,ne],le=()=>["auto","min","max","fr",oe,ne],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],V=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...C()],K=()=>[lt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],R=()=>[lt,"screen","full","dvw","lvw","svw","min","max","fit",...C()],T=()=>[lt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...C()],L=()=>[e,oe,ne],z=()=>[...S(),ns,rs,{position:[oe,ne]}],B=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ee=()=>["auto","cover","contain",Ou,_u,{size:[oe,ne]}],P=()=>[vn,er,yt],F=()=>["","none","full",u,oe,ne],U=()=>["",me,er,yt],q=()=>["solid","dashed","dotted","double"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],te=()=>[me,vn,ns,rs],_e=()=>["","none",b,oe,ne],Ie=()=>["none",me,oe,ne],Se=()=>["none",me,oe,ne],we=()=>[me,oe,ne],Le=()=>[lt,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[nt],breakpoint:[nt],color:[La],container:[nt],"drop-shadow":[nt],ease:["in","out","in-out"],font:[Ru],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[nt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[nt],shadow:[nt],spacing:["px",me],text:[nt],"text-shadow":[nt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",lt,ne,oe,y]}],container:["container"],columns:[{columns:[me,ne,oe,c]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"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:N()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:_()}],"inset-x":[{"inset-x":_()}],"inset-y":[{"inset-y":_()}],start:[{"inset-s":_(),start:_()}],end:[{"inset-e":_(),end:_()}],"inset-bs":[{"inset-bs":_()}],"inset-be":[{"inset-be":_()}],top:[{top:_()}],right:[{right:_()}],bottom:[{bottom:_()}],left:[{left:_()}],visibility:["visible","invisible","collapse"],z:[{z:[ct,"auto",oe,ne]}],basis:[{basis:[lt,"full","auto",c,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[me,lt,"auto","initial","none",ne]}],grow:[{grow:["",me,oe,ne]}],shrink:[{shrink:["",me,oe,ne]}],order:[{order:[ct,"first","last","none",oe,ne]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:ae()}],"col-start":[{"col-start":de()}],"col-end":[{"col-end":de()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:ae()}],"row-start":[{"row-start":de()}],"row-end":[{"row-end":de()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":le()}],"auto-rows":[{"auto-rows":le()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...V(),"normal"]}],"justify-self":[{"justify-self":["auto",...V()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...V(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...V(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...V(),"baseline"]}],"place-self":[{"place-self":["auto",...V()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mbs:[{mbs:Y()}],mbe:[{mbe:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],"inline-size":[{inline:["auto",...R()]}],"min-inline-size":[{"min-inline":["auto",...R()]}],"max-inline-size":[{"max-inline":["none",...R()]}],"block-size":[{block:["auto",...T()]}],"min-block-size":[{"min-block":["auto",...T()]}],"max-block-size":[{"max-block":["none",...T()]}],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,er,yt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Bu,Iu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",vn,ne]}],"font-family":[{font:[Lu,Tu,t]}],"font-features":[{"font-features":[ne]}],"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,oe,ne]}],"line-clamp":[{"line-clamp":[me,"none",oe,ts]}],leading:[{leading:[a,...C()]}],"list-image":[{"list-image":["none",oe,ne]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",oe,ne]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:L()}],"text-color":[{text:L()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...q(),"wavy"]}],"text-decoration-thickness":[{decoration:[me,"from-font","auto",oe,yt]}],"text-decoration-color":[{decoration:L()}],"underline-offset":[{"underline-offset":[me,"auto",oe,ne]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",oe,ne]}],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",oe,ne]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:z()}],"bg-repeat":[{bg:B()}],"bg-size":[{bg:ee()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ct,oe,ne],radial:["",oe,ne],conic:[ct,oe,ne]},$u,Du]}],"bg-color":[{bg:L()}],"gradient-from-pos":[{from:P()}],"gradient-via-pos":[{via:P()}],"gradient-to-pos":[{to:P()}],"gradient-from":[{from:L()}],"gradient-via":[{via:L()}],"gradient-to":[{to:L()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:U()}],"border-w-x":[{"border-x":U()}],"border-w-y":[{"border-y":U()}],"border-w-s":[{"border-s":U()}],"border-w-e":[{"border-e":U()}],"border-w-bs":[{"border-bs":U()}],"border-w-be":[{"border-be":U()}],"border-w-t":[{"border-t":U()}],"border-w-r":[{"border-r":U()}],"border-w-b":[{"border-b":U()}],"border-w-l":[{"border-l":U()}],"divide-x":[{"divide-x":U()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":U()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...q(),"hidden","none"]}],"divide-style":[{divide:[...q(),"hidden","none"]}],"border-color":[{border:L()}],"border-color-x":[{"border-x":L()}],"border-color-y":[{"border-y":L()}],"border-color-s":[{"border-s":L()}],"border-color-e":[{"border-e":L()}],"border-color-bs":[{"border-bs":L()}],"border-color-be":[{"border-be":L()}],"border-color-t":[{"border-t":L()}],"border-color-r":[{"border-r":L()}],"border-color-b":[{"border-b":L()}],"border-color-l":[{"border-l":L()}],"divide-color":[{divide:L()}],"outline-style":[{outline:[...q(),"none","hidden"]}],"outline-offset":[{"outline-offset":[me,oe,ne]}],"outline-w":[{outline:["",me,er,yt]}],"outline-color":[{outline:L()}],shadow:[{shadow:["","none",d,Sr,Nr]}],"shadow-color":[{shadow:L()}],"inset-shadow":[{"inset-shadow":["none",p,Sr,Nr]}],"inset-shadow-color":[{"inset-shadow":L()}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:L()}],"ring-offset-w":[{"ring-offset":[me,yt]}],"ring-offset-color":[{"ring-offset":L()}],"inset-ring-w":[{"inset-ring":U()}],"inset-ring-color":[{"inset-ring":L()}],"text-shadow":[{"text-shadow":["none",h,Sr,Nr]}],"text-shadow-color":[{"text-shadow":L()}],opacity:[{opacity:[me,oe,ne]}],"mix-blend":[{"mix-blend":[...se(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":se()}],"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":[me]}],"mask-image-linear-from-pos":[{"mask-linear-from":te()}],"mask-image-linear-to-pos":[{"mask-linear-to":te()}],"mask-image-linear-from-color":[{"mask-linear-from":L()}],"mask-image-linear-to-color":[{"mask-linear-to":L()}],"mask-image-t-from-pos":[{"mask-t-from":te()}],"mask-image-t-to-pos":[{"mask-t-to":te()}],"mask-image-t-from-color":[{"mask-t-from":L()}],"mask-image-t-to-color":[{"mask-t-to":L()}],"mask-image-r-from-pos":[{"mask-r-from":te()}],"mask-image-r-to-pos":[{"mask-r-to":te()}],"mask-image-r-from-color":[{"mask-r-from":L()}],"mask-image-r-to-color":[{"mask-r-to":L()}],"mask-image-b-from-pos":[{"mask-b-from":te()}],"mask-image-b-to-pos":[{"mask-b-to":te()}],"mask-image-b-from-color":[{"mask-b-from":L()}],"mask-image-b-to-color":[{"mask-b-to":L()}],"mask-image-l-from-pos":[{"mask-l-from":te()}],"mask-image-l-to-pos":[{"mask-l-to":te()}],"mask-image-l-from-color":[{"mask-l-from":L()}],"mask-image-l-to-color":[{"mask-l-to":L()}],"mask-image-x-from-pos":[{"mask-x-from":te()}],"mask-image-x-to-pos":[{"mask-x-to":te()}],"mask-image-x-from-color":[{"mask-x-from":L()}],"mask-image-x-to-color":[{"mask-x-to":L()}],"mask-image-y-from-pos":[{"mask-y-from":te()}],"mask-image-y-to-pos":[{"mask-y-to":te()}],"mask-image-y-from-color":[{"mask-y-from":L()}],"mask-image-y-to-color":[{"mask-y-to":L()}],"mask-image-radial":[{"mask-radial":[oe,ne]}],"mask-image-radial-from-pos":[{"mask-radial-from":te()}],"mask-image-radial-to-pos":[{"mask-radial-to":te()}],"mask-image-radial-from-color":[{"mask-radial-from":L()}],"mask-image-radial-to-color":[{"mask-radial-to":L()}],"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":S()}],"mask-image-conic-pos":[{"mask-conic":[me]}],"mask-image-conic-from-pos":[{"mask-conic-from":te()}],"mask-image-conic-to-pos":[{"mask-conic-to":te()}],"mask-image-conic-from-color":[{"mask-conic-from":L()}],"mask-image-conic-to-color":[{"mask-conic-to":L()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:z()}],"mask-repeat":[{mask:B()}],"mask-size":[{mask:ee()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",oe,ne]}],filter:[{filter:["","none",oe,ne]}],blur:[{blur:_e()}],brightness:[{brightness:[me,oe,ne]}],contrast:[{contrast:[me,oe,ne]}],"drop-shadow":[{"drop-shadow":["","none",g,Sr,Nr]}],"drop-shadow-color":[{"drop-shadow":L()}],grayscale:[{grayscale:["",me,oe,ne]}],"hue-rotate":[{"hue-rotate":[me,oe,ne]}],invert:[{invert:["",me,oe,ne]}],saturate:[{saturate:[me,oe,ne]}],sepia:[{sepia:["",me,oe,ne]}],"backdrop-filter":[{"backdrop-filter":["","none",oe,ne]}],"backdrop-blur":[{"backdrop-blur":_e()}],"backdrop-brightness":[{"backdrop-brightness":[me,oe,ne]}],"backdrop-contrast":[{"backdrop-contrast":[me,oe,ne]}],"backdrop-grayscale":[{"backdrop-grayscale":["",me,oe,ne]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[me,oe,ne]}],"backdrop-invert":[{"backdrop-invert":["",me,oe,ne]}],"backdrop-opacity":[{"backdrop-opacity":[me,oe,ne]}],"backdrop-saturate":[{"backdrop-saturate":[me,oe,ne]}],"backdrop-sepia":[{"backdrop-sepia":["",me,oe,ne]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",oe,ne]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[me,"initial",oe,ne]}],ease:[{ease:["linear","initial",x,oe,ne]}],delay:[{delay:[me,oe,ne]}],animate:[{animate:["none",w,oe,ne]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,oe,ne]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:Ie()}],"rotate-x":[{"rotate-x":Ie()}],"rotate-y":[{"rotate-y":Ie()}],"rotate-z":[{"rotate-z":Ie()}],scale:[{scale:Se()}],"scale-x":[{"scale-x":Se()}],"scale-y":[{"scale-y":Se()}],"scale-z":[{"scale-z":Se()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[oe,ne,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Le()}],"translate-x":[{"translate-x":Le()}],"translate-y":[{"translate-y":Le()}],"translate-z":[{"translate-z":Le()}],"translate-none":["translate-none"],accent:[{accent:L()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:L()}],"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",oe,ne]}],"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":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",oe,ne]}],fill:[{fill:["none",...L()]}],"stroke-w":[{stroke:[me,er,yt,ts]}],stroke:[{stroke:["none",...L()]}],"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"]}},Gu=yu(zu);function A(...e){return Gu(Aa(e))}function Qu(e){if(e==null||typeof e!="object")return null;const t=Reflect.get(e,"data");if(t!=null&&typeof t=="object"){const r=Reflect.get(t,"capRouteReason");if(typeof r=="string")return r}return null}function Zr(e){const t=Qu(e);return t!==null?t==="no-provider"||t==="node-offline":(e instanceof Error?e.message:String(e)).includes("provider not available")}var Hy="rounded-lg border border-border bg-surface overflow-hidden",Vy="border-b border-border px-3 sm:px-4 py-1.5 sm:py-2",Wy="p-2 sm:p-3 lg:p-4",qy="space-y-3 sm:space-y-4",Ky="gap-2 sm:gap-3",Zy="px-3 sm:px-4 py-1.5 sm:py-2",Yy="grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4",Xy="grid grid-cols-1 lg:grid-cols-2",Jy="flex flex-col-reverse md:flex-row",e0="w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border",t0="text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider",r0="text-[11px] sm:text-xs text-foreground",ot="text-[10px] text-foreground-subtle",n0="text-[11px] sm:text-xs font-medium text-foreground",o0="text-base sm:text-lg font-semibold leading-tight text-foreground",s0="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",a0="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",i0="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",l0="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",c0="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",u0="inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors",d0="border-primary/50 bg-primary/15 text-primary",p0="border-border bg-surface text-foreground-subtle hover:bg-surface-hover";function ju(e,t){for(const r of e.slots)for(const n of r.addons)if(n.id===t)return n;return null}function Uu(e,t){return e.models.find(r=>r.id===t)??null}function Hu(e,t){return e.models.find(r=>!!r.formats[t])??null}function Vu(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 f0(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=ju(n,i);if(!l){a.push({addonId:i,outcome:"skip",modelId:null,reason:"addon not in target catalog",patch:null});continue}const u=Uu(l,c.modelId),d=u!==null&&!!u.formats[r.engine.format];let p,h;if(d)p=c.modelId,h="exact";else{const b=Hu(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:Vu(c.settings,l)};a.push({addonId:i,outcome:h,modelId:p,patch:g})}return a}var os={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 ja(e){return os[e]??os.watching}function ht(e,t){if(typeof globalThis>"u")return st(t);const r=globalThis.__camstackSharedContexts,n=r??new Map;r||(globalThis.__camstackSharedContexts=n);const s=n.get(e);if(s)return s;const a=st(t);return n.set(e,a),a}var Wu="FEDERATION_DEBUG",jn=(function(e){return e[e.UNKNOWN=1]="UNKNOWN",e[e.CALCULATED=2]="CALCULATED",e[e.NO_USE=0]="NO_USE",e})({}),Ua=!0;function qu(){return Ua}function Ku(){try{if(qu()&&window.localStorage)return!!localStorage.getItem(Wu)}catch{return!1}return!1}function Un(){return typeof process<"u"&&bn&&bn.FEDERATION_DEBUG?!!bn.FEDERATION_DEBUG:typeof FEDERATION_DEBUG<"u"&&FEDERATION_DEBUG?!0:Ku()}var Zu="[ Federation Runtime ]",Ha=function(...e){return e.length?e.reduce((t,r)=>r?t?`${t}:${r}`:r:t,""):""},Hn=(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),"")},Va=e=>{console.warn(`${Zu}: ${e}`)};function Wa(e){try{return JSON.stringify(e,null,2)}catch{return""}}var yn=(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 Yu(e){return e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")}function Xu(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?Yu(s):e.metaData.publicPath:e.metaData.getPublicPath,c=Object.keys(n);let l={};Object.keys(r).length||(l=e.remotes?.reduce((w,k)=>{let S;const N=k.federationContainerName;return c.includes(N)?S=n[N]:"version"in k?S=k.version:S=k.entry,w[N]={matchedVersion:S},w},{})||{}),Object.keys(r).forEach(w=>l[w]={matchedVersion:c.includes(w)?n[w]:r[w]});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:yn(u,d),remoteEntryType:p,remoteTypes:yn(h.path,h.name),remoteTypesZip:h.zip||"",remoteTypesAPI:h.api||"",remotesInfo:l,shared:e?.shared.map(w=>({assets:w.assets,sharedName:w.name,version:w.version,usedExports:w.referenceExports||[]})),modules:y?.map(w=>({moduleName:w.name,modulePath:w.path,assets:w.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 w=yn(v.path,v.name);a.ssrRemoteEntry=w,a.ssrRemoteEntryType=v.type||"commonjs-module"}return a}function qa(e){return!!("remoteEntry"in e&&e.remoteEntry.includes(".json"))}var Ju="[ Module Federation ]",tr=console,ed=["logger.ts","logger.js","captureStackTrace","Logger.emit","Logger.log","Logger.info","Logger.warn","Logger.error","Logger.debug"];function td(){try{const e=new Error().stack;if(!e)return;const[,...t]=e.split(`
31
+ `),r=t.filter(n=>!ed.some(s=>n.includes(s)));return r.length?`Stack trace:
32
+ ${r.slice(0,5).join(`
33
+ `)}`:void 0}catch{return}}var Ka=class{constructor(e,t=tr){this.prefix=e,this.delegate=t??tr}setPrefix(e){this.prefix=e}setDelegate(e){this.delegate=e??tr}emit(e,t){const r=this.delegate,n=Un()?td():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=tr[i];if(typeof c=="function"){c.call(tr,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){Un()&&this.emit("debug",e)}};function rd(e){return new Ka(e)}function nd(e){const t=new Ka(e);return Object.defineProperty(t,"__mf_infrastructure_logger__",{value:!0,enumerable:!1,configurable:!1}),t}nd(Ju);async function Za(e,t){try{return await e()}catch(r){Va(r);return}}function Vn(e,t){const r=/^(https?:)?\/\//i;return e.replace(r,"").replace(/\/$/,"")===t.replace(r,"").replace(/\/$/,"")}function Ya(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&&Vn(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&&Vn(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,Za(()=>{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 xn(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&&Vn(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,Za(()=>{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 od(e,t){const{attrs:r={},createScriptHook:n}=t;return new Promise((s,a)=>{const{script:i,needAttach:c}=Ya({url:e,cb:s,onErrorCallback:a,attrs:{fetchpriority:"high",...r},createScriptHook:n,needDeleteScript:!0});c&&document.head.appendChild(i)})}var sd=e=>`View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${e.split("-")[0].toLowerCase()}#${e.toLowerCase()}`,Xa=(e,t,r,n)=>{const s=[`${[t[e]]} #${e}`];return r&&s.push(`args: ${JSON.stringify(r)}`),s.push(sd(e)),n&&s.push(`Original Error Message:
34
+ ${n}`),s.join(`
35
+ `)};function ad(e,t,r,n,s,a){return n(Xa(e,t,r,s))}var kt="[ Federation Runtime ]",Wn=rd(kt);function $e(e,t,r,n,s){e||(r!==void 0?Ne(t,r,n,void 0):Ne(t))}function Ne(e,t,r,n,s){if(t!==void 0)return ad(e,t,r??{},i=>{throw new Error(`${kt}: ${i}`)},n);const a=e;throw a instanceof Error?(a.message.startsWith(kt)||(a.message=`${kt}: ${a.message}`),a):new Error(`${kt}: ${a}`)}function So(e){e instanceof Error&&(e.message.startsWith(kt)||(e.message=`${kt}: ${e.message}`)),Wn.warn(e)}function id(e,t){return e.findIndex(r=>r===t)===-1&&e.push(t),e}function dr(e){return"version"in e&&e.version?`${e.name}:${e.version}`:"entry"in e&&e.entry?`${e.name}:${e.entry}`:`${e.name}`}function Co(e){return typeof e.entry<"u"}function Ja(e){return!e.entry.includes(".json")}function Mo(e){return e&&typeof e=="object"}var ld=Object.prototype.toString;function cd(e){return ld.call(e)==="[object Object]"}function ei(e){return Array.isArray(e)?e:[e]}function ti(e){const t={url:"",type:"global",globalName:""};return"remoteEntry"in e?{url:e.remoteEntry,type:e.remoteEntryType,globalName:e.globalName}:t}var ud=(e,t)=>{let r;return e.endsWith("/")?r=e.slice(0,-1):r=e,t.startsWith(".")&&(t=t.slice(1)),r=r+t,r},Me=typeof globalThis=="object"?globalThis:window,We=(()=>{try{return document.defaultView}catch{return Me}})(),pr=We;function zr(e,t,r){Object.defineProperty(e,t,{value:r,configurable:!1,writable:!0})}function Gr(e,t){return Object.hasOwnProperty.call(e,t)}Gr(Me,"__GLOBAL_LOADING_REMOTE_ENTRY__")||zr(Me,"__GLOBAL_LOADING_REMOTE_ENTRY__",{});var Lt=Me.__GLOBAL_LOADING_REMOTE_ENTRY__;function ri(e){Gr(e,"__VMOK__")&&!Gr(e,"__FEDERATION__")&&zr(e,"__FEDERATION__",e.__VMOK__),Gr(e,"__FEDERATION__")||(zr(e,"__FEDERATION__",{__GLOBAL_PLUGIN__:[],__INSTANCES__:[],moduleInfo:{},__SHARE__:{},__MANIFEST_LOADING__:{},__PRELOADED_MAP__:new Map}),zr(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}ri(Me);ri(We);function dd(e){Me.__FEDERATION__.__INSTANCES__.push(e)}function pd(){return Me.__FEDERATION__.__DEBUG_CONSTRUCTOR__}function fd(e,t=Un()){t&&(Me.__FEDERATION__.__DEBUG_CONSTRUCTOR__=e,Me.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__="2.4.0")}function Ut(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 Ne(`getInfoWithoutType: "key" must be a string, got ${typeof t} (${JSON.stringify(t)}).`)}var ss=()=>We.__FEDERATION__.moduleInfo,md=(e,t)=>{const r=Ut(t,dr(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=dr(s),i=Ut(We.__FEDERATION__.moduleInfo,a).value;if(i?.version===n)return i}},Qr=e=>md(e,We.__FEDERATION__.moduleInfo),as=(e,t)=>{const r=dr(e);return We.__FEDERATION__.moduleInfo[r]=t,We.__FEDERATION__.moduleInfo},hd=e=>(We.__FEDERATION__.moduleInfo={...We.__FEDERATION__.moduleInfo,...e},()=>{const t=Object.keys(e);for(const r of t)delete We.__FEDERATION__.moduleInfo[r]}),ni=(e,t)=>{const r=t||`__FEDERATION_${e}:custom__`;return{remoteEntryKey:r,entryExports:Me[r]}},gd=()=>We.__FEDERATION__.__GLOBAL_PLUGIN__,bd=e=>Me.__FEDERATION__.__PRELOADED_MAP__.get(e),vd=e=>Me.__FEDERATION__.__PRELOADED_MAP__.set(e,!0),is="[0-9A-Za-z-]+",Eo=`(?:\\+(${is}(?:\\.${is})*))`,sr="0|[1-9]\\d*",jr="[0-9]+",oi="\\d*[a-zA-Z-][a-zA-Z0-9-]*",ls=`(?:${jr}|${oi})`,yd=`(?:-?(${ls}(?:\\.${ls})*))`,cs=`(?:${sr}|${oi})`,si=`(?:-(${cs}(?:\\.${cs})*))`,wn=`${sr}|x|X|\\*`,Ht=`[v=\\s]*(${wn})(?:\\.(${wn})(?:\\.(${wn})(?:${si})?${Eo}?)?)?`,xd=`^\\s*(${Ht})\\s+-\\s+(${Ht})\\s*$`,wd=`[v=\\s]*${`(${jr})\\.(${jr})\\.(${jr})`}${yd}?${Eo}?`,Ao="((?:<|>)?=?)",kd=`(\\s*)${Ao}\\s*(${wd}|${Ht})`,ai="(?:~>?)",Nd=`(\\s*)${ai}\\s+`,ii="(?:\\^)",Sd=`(\\s*)${ii}\\s+`,Cd="(<|>)?=?\\s*\\*",Md=`^${ii}${Ht}$`,Ed=`v?${`(${sr})\\.(${sr})\\.(${sr})`}${si}?${Eo}?`,Ad=`^${ai}${Ht}$`,Pd=`^${Ao}\\s*${Ht}$`,Rd=`^${Ao}\\s*(${Ed})$|^$`,_d="^\\s*>=\\s*0.0.0\\s*$";function Je(e){return new RegExp(e)}function Te(e){return!e||e.toLowerCase()==="x"||e==="*"}function li(...e){return t=>e.reduce((r,n)=>n(r),t)}function us(e){return e.match(Je(Rd))}function ds(e,t,r,n){const s=`${e}.${t}.${r}`;return n?`${s}-${n}`:s}function Id(e){return e.replace(Je(xd),(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 Td(e){return e.replace(Je(kd),"$1$2$3")}function Dd(e){return e.replace(Je(Nd),"$1~")}function Ld(e){return e.replace(Je(Sd),"$1^")}function Od(e){return e.trim().split(/\s+/).map(t=>t.replace(Je(Md),(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 $d(e){return e.trim().split(/\s+/).map(t=>t.replace(Je(Ad),(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 Bd(e){return e.split(/\s+/).map(t=>t.trim().replace(Je(Pd),(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 Fd(e){return e.trim().replace(Je(Cd),"")}function zd(e){return e.trim().replace(Je(_d),"")}function Ur(e,t){return e=Number(e)||e,t=Number(t)||t,e>t?1:e===t?0:-1}function Gd(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?Ur(i,c):-1:1}return 0}function Cr(e,t){return Ur(e.major,t.major)||Ur(e.minor,t.minor)||Ur(e.patch,t.patch)||Gd(e,t)}function kn(e,t){return e.version===t.version}function Qd(e,t){switch(e.operator){case"":case"=":return kn(e,t);case">":return Cr(e,t)<0;case">=":return kn(e,t)||Cr(e,t)<0;case"<":return Cr(e,t)>0;case"<=":return kn(e,t)||Cr(e,t)>0;case void 0:return!0;default:return!1}}function jd(e){return li(Od,$d,Bd,Fd)(e)}function Ud(e){return li(Id,Td,Dd,Ld)(e.trim()).split(/\s+/).join(" ")}function or(e,t){if(!e)return!1;const r=us(e);if(!r)return!1;const[,n,,s,a,i,c]=r,l={operator:n,version:ds(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=Ud(p);if(!h.trim())return!0;const g=h.split(" ").map(y=>jd(y)).join(" ");if(!g.trim())return!0;const b=g.split(/\s+/).map(y=>zd(y)).filter(Boolean);if(b.length===0)continue;let v=!0;for(const y of b){const x=us(y);if(!x){v=!1;break}const[,w,,k,S,N,E]=x;if(!Qd({operator:w,version:ds(k,S,N,E),major:k,minor:S,patch:N,preRelease:E?.split(".")},l)){v=!1;break}}if(v)return!0}catch(h){console.error(`[semver] Error processing range part "${p}":`,h);continue}}return!1}var on="default",Hd="global";function Vd(e,t,r,n){let s;return"get"in e?s=e.get:"lib"in e?s=()=>Promise.resolve(e.lib):s=()=>Promise.resolve(()=>{Ne(`Cannot get shared "${r}" from "${t}": neither "get" nor "lib" is provided in the share config.`)}),e.shareConfig?.eager&&e.treeShaking?.mode&&Ne(`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??jn.UNKNOWN,useIn:[]}:void 0}}function ci(e,t){const r=t.shared||{},n=t.name,s=Object.keys(r).reduce((i,c)=>{const l=ei(r[c]);return i[c]=i[c]||[],l.forEach(u=>{i[c].push(Vd(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 fr(e,t){if(!e)return!1;const{status:r,mode:n}=e;return r===jn.NO_USE?!1:r===jn.CALCULATED?!0:n==="runtime-infer"?t?qd(e,t):!0:!1}function Nt(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!!or(r(e),`<=${r(t)}`)}var mr=(e,t)=>{const r=t||function(n,s){return Nt(n,s)};return Object.keys(e).reduce((n,s)=>!n||r(n,s)||n==="0"?s:n,0)},Yr=e=>!!e.loaded||typeof e.lib=="function",Wd=e=>!!e.loading,qd=(e,t)=>{if(!e||!t)return!1;const{usedExports:r}=e;return r?!!t.every(n=>r.includes(n)):!1};function Kd(e,t,r,n){const s=e[t][r];let a="",i=fr(n);const c=function(l,u){return i?s[l].treeShaking?s[u].treeShaking?!Yr(s[l].treeShaking)&&Nt(l,u):!1:!0:!Yr(s[l])&&Nt(l,u)};if(i){if(a=mr(e[t][r],c),a)return{version:a,useTreesShaking:i};i=!1}return{version:mr(e[t][r],c),useTreesShaking:i}}var _t=e=>Yr(e)||Wd(e);function Zd(e,t,r,n){const s=e[t][r];let a="",i=fr(n);const c=function(l,u){if(i){if(!s[l].treeShaking)return!0;if(!s[u].treeShaking)return!1;if(_t(s[u].treeShaking))return _t(s[l].treeShaking)?!!Nt(l,u):!0;if(_t(s[l].treeShaking))return!1}return _t(s[u])?_t(s[l])?!!Nt(l,u):!0:_t(s[l])?!1:Nt(l,u)};if(i){if(a=mr(e[t][r],c),a)return{version:a,useTreesShaking:i};i=!1}return{version:mr(e[t][r],c),useTreesShaking:i}}function Yd(e){return e==="loaded-first"?Zd:Kd}function Hr(e,t,r,n){if(!e)return;const{shareConfig:s,scope:a=on,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}=Yd(i)(e,u,t,c),g=()=>{const v=e[u][t][p];if(s.singleton){if(typeof d=="string"&&!or(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?Ne(y):So(y)}return{shared:v,useTreesShaking:h}}else{if(d===!1||d==="*")return{shared:v,useTreesShaking:h};if(or(p,d))return{shared:v,useTreesShaking:h};const y=fr(c);if(y){for(const[x,w]of Object.entries(e[u][t]))if(fr(w.treeShaking,c?.usedExports)&&or(x,d))return{shared:w,useTreesShaking:y}}for(const[x,w]of Object.entries(e[u][t]))if(or(x,d))return{shared:w,useTreesShaking:!1}}},b={shareScopeMap:e,scope:u,pkgName:t,version:p,GlobalFederation:pr.__FEDERATION__,shareInfo:r,resolver:g};return(n.emit(b)||b).resolver()}}function ui(){return pr.__FEDERATION__.__SHARE__}function ps(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[mr(u,function(p,h){return!Yr(u[p])&&Nt(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 It=(e,t)=>{e.useIn||(e.useIn=[]),id(e.useIn,t)};function Mr(e,t){return t&&e.treeShaking?e.treeShaking:e}function Xd(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 Jd(e,t){for(const r of e)if(t===r.name||r.alias&&t===r.alias)return r}var di="RUNTIME-001",pi="RUNTIME-002",fi="RUNTIME-003",mi="RUNTIME-004",hi="RUNTIME-005",qn="RUNTIME-006",gi="RUNTIME-007",bi="RUNTIME-008",Po="RUNTIME-009",vi="RUNTIME-010",yi="RUNTIME-011",ep="RUNTIME-012",Be={[di]:"Failed to get remoteEntry exports.",[pi]:'The remote entry interface does not contain "init"',[fi]:"Failed to get manifest.",[mi]:"Failed to locate remote.",[hi]:"Invalid loadShareSync function call from bundler runtime",[qn]:"Invalid loadShareSync function call from runtime",[gi]:"Failed to get remote snapshot.",[bi]:"Failed to load script resources.",[Po]:"Please call createInstance first.",[vi]:'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',[yi]:"The remoteEntry URL is missing from the remote snapshot.",[ep]:'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.'};({...Be});var xi=".then(callbacks[0]).catch(callbacks[1])";async function tp({entry:e,remoteEntryExports:t}){return new Promise((r,n)=>{try{t?r(t):typeof FEDERATION_ALLOW_NEW_FUNCTION<"u"?new Function("callbacks",`import("${e}")${xi}`)([r,n]):import(e).then(r).catch(n)}catch(s){Ne(`Failed to load ESM entry from "${e}". ${s instanceof Error?s.message:String(s)}`)}})}async function rp({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}")${xi}`)([r,n])}catch(s){Ne(`Failed to load SystemJS entry from "${e}". ${s instanceof Error?s.message:String(s)}`)}})}function np(e,t,r){const{remoteEntryKey:n,entryExports:s}=ni(e,t);return s||Ne(di,Be,{remoteName:e,remoteEntryUrl:r,remoteEntryKey:n}),s}async function op({name:e,globalName:t,entry:r,remoteInfo:n,loaderHook:s,getEntryUrl:a}){const{entryExports:i}=ni(e,t);if(i)return i;const c=a?a(r):r;return od(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(()=>np(e,t,r),l=>{const u=l instanceof Error?l.message:String(l);Ne(bi,Be,{remoteName:e,resourceUrl:c},u)})}async function sp({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 tp({entry:s,remoteEntryExports:t});case"system":return rp({entry:s,remoteEntryExports:t});default:return op({entry:s,globalName:a,name:i,remoteInfo:e,loaderHook:r,getEntryUrl:n})}}function Kn(e){const{entry:t,name:r}=e;return Ha(r,t)}async function Xr(e){const{origin:t,remoteEntryExports:r,remoteInfo:n,getEntryUrl:s,_inErrorHandling:a=!1}=e,i=Kn(n);if(r)return r;if(!Lt[i]){const c=t.remoteHandler.hooks.lifecycle.loadEntry,l=t.loaderHook;Lt[i]=c.emit({loaderHook:l,remoteInfo:n,remoteEntryExports:r}).then(u=>u||sp({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=>Xr({...b,_inErrorHandling:!0}),g=await t.loaderHook.lifecycle.loadEntryError.emit({getRemoteEntry:h,origin:t,remoteInfo:n,remoteEntryExports:r,globalLoading:Lt,uniqueKey:d});if(g)return g}throw u})}return Lt[i]}function Jr(e){return{...e,entry:"entry"in e?e.entry:"",type:e.type||"global",entryGlobalName:e.entryGlobalName||e.name,shareScope:e.shareScope||"default"}}function ap(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function ip(e,t){const r=gd(),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 lp(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 Vt(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(lp)??[],shared:t}}}function wi(e){return{resourceCategory:"sync",share:!0,depsRemote:!0,...e}}function cp(e,t){return t.map(r=>{const n=Jd(e,r.nameOrAlias);return $e(n,`Unable to preload ${r.nameOrAlias} as it is not included in ${!n&&Wa({remoteInfo:n,remotes:e})}`),{remote:n,preloadConfig:wi(r)}})}function up(e){return e?e.map(t=>t==="."?t:t.startsWith("./")?t.replace("./",""):t):[]}function ki(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);Xr(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}=xn({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}=xn({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}=xn({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}=Ya({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 dp(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 Ni=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 Xr({origin:this.host,remoteInfo:this.remoteInfo,remoteEntryExports:this.remoteEntryExports});return $e(e,`remoteEntryExports is undefined
36
+ ${Wa(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}=dp(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"&&Ne(pi,Be,{hostName:this.host.name,remoteName:this.remoteInfo.name,remoteEntryUrl:this.remoteInfo.entry,remoteEntryKey:this.remoteInfo.entryGlobalName},void 0,Vt(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)),$e(i,`${dr(this.remoteInfo)} remote don't export ${t}.`);const c=ud(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()}},He=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 Si(e,t){if(!Mo(t))return!1;if(e!==t){for(const r in e)if(!(r in t))return!1}return!0}var Ft=class extends Qe{constructor(e){super(),this.onerror=Ne,this.type=e}emit(e){Mo(e)||Ne(`The data for the "${this.type}" hook should be an object.`);for(const t of this.listeners)try{const r=t(e);if(Si(e,r))e=r;else{this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);break}}catch(r){So(r),this.onerror(r)}return e}},pt=class extends Qe{constructor(e){super(),this.onerror=Ne,this.type=e}emit(e){Mo(e)||Ne(`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=>(So(a),this.onerror(a),e),s=a=>{if(Si(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)}},zt=class{constructor(e){this.registerPlugins={},this.lifecycle=e,this.lifecycleKeys=Object.keys(e)}applyPlugin(e,t){$e(cd(e),"Plugin configuration is invalid.");const r=e.name;$e(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){$e(e,"A name is required.");const t=this.registerPlugins[e];$e(t,`The plugin "${e}" is not registered.`),Object.keys(t).forEach(r=>{r!=="name"&&this.lifecycle[r].remove(t[r])})}};function Ci(e,t){const r=ti(t);r.url||Ne(yi,Be,{remoteName:e.name});let n=Hn(t,r.url);e.type=r.type,e.entryGlobalName=r.globalName,e.entry=n,e.version=t.version,e.buildVersion=t.buildVersion}function pp(){return{name:"snapshot-plugin",async afterResolve(e){const{remote:t,pkgNameOrAlias:r,expose:n,origin:s,remoteInfo:a,id:i}=e;if(!Co(t)||!Ja(t)){const{remoteSnapshot:c,globalSnapshot:l}=await s.snapshotHandler.loadRemoteSnapshotInfo({moduleInfo:t,id:i});Ci(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&&ki(a,s,d,!1),{...e,remoteSnapshot:c}}return e}}}function fp(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 Mi(e,t,r,n,s={},a){const{value:i}=Ut(e,dr(t)),c=a||i;if(c&&!qa(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=fp(u),p=c.remotesInfo[u];Mi(e,{name:d.name,version:p.matchedVersion},r,!1,s,void 0)}}}var Nn=(e,t)=>document.querySelector(`${e}[${e==="link"?"href":"src"}="${t}"]`);function mp(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(Mi(n,r,(b,v,y)=>{let x;if(y)x=p;else if(Array.isArray(h)){const E=h.find(D=>D.nameOrAlias===v.name||D.nameOrAlias===v.alias);if(!E)return;x=wi(E)}else if(h===!0)x=p;else return;const w=Hn(b,ti(b).url);w&&c.push({name:v.name,moduleInfo:{name:v.name,entry:w,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:w});let k="modules"in b?b.modules:[];const S=up(x.exposes);S.length&&"modules"in b&&(k=b?.modules?.reduce((E,D)=>(S?.indexOf(D.moduleName)!==-1&&E.push(D),E),[]));function N(E){const D=E.map(C=>Hn(b,C));return x.filter?D.filter(x.filter):D}if(k){const E=k.length;for(let D=0;D<E;D++){const C=k[D],_=`${v.name}/${C.moduleName}`;e.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({id:C.moduleName==="."?v.name:_,name:v.name,remoteSnapshot:b,preloadConfig:x,remote:v,origin:e}),!bd(_)&&(x.resourceCategory==="all"?(a.push(...N(C.assets.css.async)),a.push(...N(C.assets.css.sync)),i.push(...N(C.assets.js.async)),i.push(...N(C.assets.js.sync))):x.resourceCategory==="sync"&&(a.push(...N(C.assets.css.sync)),i.push(...N(C.assets.js.sync))),vd(_))}}},!0,{},s),s.shared&&s.shared.length>0){const b=(v,y)=>{const{shared:x}=Hr(e.shareScopeMap,y.sharedName,v,e.sharedHandler.hooks.lifecycle.resolveShare)||{};x&&typeof x.lib=="function"&&(y.assets.js.sync.forEach(w=>{l.add(w)}),y.assets.css.sync.forEach(w=>{u.add(w)}))};s.shared.forEach(v=>{const y=d.shared?.[v.sharedName];if(!y)return;const x=v.version?y.find(w=>w.version===v.version):y;x&&ei(x).forEach(w=>{b(w,v)})})}const g=i.filter(b=>!l.has(b)&&!Nn("script",b));return{cssAssets:a.filter(b=>!u.has(b)&&!Nn("link",b)),jsAssetsWithoutEntry:g,entryAssets:c.filter(b=>!Nn("script",b.url))}}var hp=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 Co(s)&&Ja(s)?{cssAssets:[],jsAssetsWithoutEntry:[],entryAssets:[{name:s.name,url:s.entry,moduleInfo:{name:n.name,entry:s.entry,type:n.type||"global",entryGlobalName:"",shareScope:""}}]}:(Ci(n,i),mp(t,r,n,a,i))}}};function Ei(e,t){const r=Qr({name:t.name,version:t.options.version}),n=r&&"remotesInfo"in r&&r.remotesInfo&&Ut(r.remotesInfo,e.name).value;return n&&n.matchedVersion?{hostGlobalSnapshot:r,globalSnapshot:ss(),remoteSnapshot:Qr({name:e.name,version:n.matchedVersion})}:{hostGlobalSnapshot:void 0,globalSnapshot:ss(),remoteSnapshot:Qr({name:e.name,version:"version"in e?e.version:void 0})}}var gp=class{constructor(e){this.loadingHostSnapshot=null,this.manifestCache=new Map,this.hooks=new zt({beforeLoadRemoteSnapshot:new He("beforeLoadRemoteSnapshot"),loadSnapshot:new pt("loadGlobalSnapshot"),loadRemoteSnapshot:new pt("loadRemoteSnapshot"),afterLoadSnapshot:new pt("afterLoadSnapshot")}),this.manifestLoading=pr.__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=Qr({name:this.HostInstance.options.name,version:this.HostInstance.options.version});s||(s={version:this.HostInstance.options.version||"",remoteEntry:"",remotesInfo:{}},hd({[this.HostInstance.options.name]:s})),s&&"remotesInfo"in s&&!Ut(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(qa(l)){const h=l.remoteEntry,g=await this.getManifestJson(h,e,{}),b=as({...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(Co(e)){const h=await this.getManifestJson(e.entry,e,{}),g=as(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 Ne(gi,Be,{remoteName:e.name,remoteVersion:e.version,hostName:this.HostInstance.options.name,globalSnapshot:JSON.stringify(u)},void 0,Vt(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 Ei(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,{},Jr(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],Ne(fi,Be,{manifestUrl:e,moduleName:t.name,hostName:this.HostInstance.options.name},`${i}`,Vt(this.HostInstance.options)))}return $e(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=Xu(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]}},bp=class{constructor(e){this.hooks=new zt({beforeRegisterShare:new Ft("beforeRegisterShare"),afterResolve:new pt("afterResolve"),beforeLoadShare:new pt("beforeLoadShare"),loadShare:new He,resolveShare:new Ft("resolveShare"),initContainerShareScopeMap:new Ft("initContainerShareScopeMap")}),this.host=e,this.shareScopeMap={},this.initTokens={},this._setGlobalShareScopeMap(e.options)}registerShared(e,t){const{newShareInfos:r,allShareInfos:n}=ci(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=ps({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});$e(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}=Hr(this.shareScopeMap,e,s,this.hooks.lifecycle.resolveShare)||{};if(a){const c=Mr(a,i);if(c.lib)return It(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),It(c,r.options.name),l}else{const u=(async()=>{const d=await c.get();return It(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=fr(s.treeShaking),l=Mr(s,c),d=(async()=>{const p=await l.get();l.lib=p,l.loaded=!0,It(l,r.options.name);const{shared:h,useTreesShaking:g}=Hr(this.shareScopeMap,e,s,this.hooks.lifecycle.resolveShare)||{};if(h){const b=Mr(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=on,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]&&Mr(y[b]),w=!!(x&&("eager"in x&&x.eager||"shareConfig"in x&&x.shareConfig?.eager));(!x||x.strategy!=="loaded-first"&&!x.loaded&&(!v!=!w?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=ps({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}=Hr(this.shareScopeMap,e,n,this.hooks.lifecycle.resolveShare)||{};if(s){if(typeof s.lib=="function")return It(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 It(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&&Ne(t?.from==="build"?hi:qn,Be,{hostName:r.options.name,sharedPkgName:e},void 0,Vt(r.options)),n.lib=i,this.setShared({pkgName:e,loaded:!0,from:r.options.name,lib:n.lib,shared:n}),n.lib}Ne(qn,Be,{hostName:r.options.name,sharedPkgName:e},void 0,Vt(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,w)=>{w&&!y[x]&&(y[x]=w)},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=ui(),r=e.id||e.name;r&&!t[r]&&(t[r]=this.shareScopeMap)}},vp=class{constructor(e){this.hooks=new zt({beforeRegisterRemote:new Ft("beforeRegisterRemote"),registerRemote:new Ft("registerRemote"),beforeRequest:new pt("beforeRequest"),onLoad:new He("onLoad"),handlePreloadModule:new Qe("handlePreloadModule"),errorLoadRemote:new He("errorLoadRemote"),beforePreloadRemote:new He("beforePreloadRemote"),generatePreloadAssets:new He("generatePreloadAssets"),afterPreloadRemote:new He,loadEntry:new He}),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=cp(t.options.remotes,e);await Promise.all(r.map(async n=>{const{remote:s}=n,a=Jr(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&&ki(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=Xd(t.options.remotes,s);a||Ne(mi,Be,{hostName:t.options.name,requestId:s},void 0,Vt(t.options));const{remote:i}=a,c=Jr(i),l=await t.sharedHandler.hooks.lifecycle.afterResolve.emit({id:s,...a,options:t.options,origin:t,remoteInfo:c}),{remote:u,expose:d}=l;$e(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 Ni(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)));$e(!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=on),e.type||(e.type=Hd)};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}),Va(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;Me[i]&&(Object.getOwnPropertyDescriptor(Me,i)?.configurable?delete Me[i]:Me[i]=void 0);const c=Kn(s.remoteInfo);Lt[c]&&delete Lt[c],t.snapshotHandler.manifestCache.delete(a.entry);let l=a.buildVersion?Ha(a.name,a.buildVersion):a.name;const u=Me.__FEDERATION__.__INSTANCES__.findIndex(p=>a.buildVersion?p.options.id===l:p.name===l);if(u!==-1){const p=Me.__FEDERATION__.__INSTANCES__[u];l=p.options.id||l;const h=ui();let g=!0;const b=[];Object.keys(h).forEach(v=>{const y=h[v];y&&Object.keys(y).forEach(x=>{const w=y[x];w&&Object.keys(w).forEach(k=>{const S=w[k];S&&Object.keys(S).forEach(N=>{const E=S[N];E&&typeof E=="object"&&E.from===a.name&&(E.loaded||E.loading?(E.useIn=E.useIn.filter(D=>D!==a.name),E.useIn.length?g=!1:b.push([v,x,k,N])):b.push([v,x,k,N]))})})})}),g&&(p.shareScopeMap={},delete h[l]),b.forEach(([v,y,x,w])=>{delete h[v]?.[y]?.[x]?.[w]}),Me.__FEDERATION__.__INSTANCES__.splice(u,1)}const{hostGlobalSnapshot:d}=Ei(e,t);if(d){const p=d&&"remotesInfo"in d&&d.remotesInfo&&Ut(d.remotesInfo,e.name).key;p&&(delete d.remotesInfo[p],pr.__FEDERATION__.__MANIFEST_LOADING__[p]&&delete pr.__FEDERATION__.__MANIFEST_LOADING__[p])}t.moduleCache.delete(e.name)}}catch(t){Wn.error(`removeRemote failed: ${t instanceof Error?t.message:String(t)}`)}}},yp=typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN=="boolean"?!FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN:!0,Ai=class{constructor(e){this.hooks=new zt({beforeInit:new Ft("beforeInit"),init:new Qe,beforeInitContainer:new pt("beforeInitContainer"),initContainer:new pt("initContainer")}),this.version="2.4.0",this.moduleCache=new Map,this.loaderHook=new zt({getModuleInfo:new Qe,createScript:new Qe,createLink:new Qe,fetch:new He,loadEntryError:new He,getModuleFactory:new He}),this.bridgeHook=new zt({beforeBridgeRender:new Qe,afterBridgeRender:new Qe,beforeBridgeDestroy:new Qe,afterBridgeDestroy:new Qe});const t=yp?[pp(),hp()]:[],r={id:ap(),name:e.name,plugins:t,remotes:[],shared:{},inBrowser:Ua};this.name=e.name,this.options=r,this.snapshotHandler=new gp(this),this.sharedHandler=new bp(this),this.remoteHandler=new vp(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&&Ne(Xa(vi,Be)),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=on,t){return this.sharedHandler.initializeSharing(e,t)}initRawContainer(e,t,r){const n=Jr({name:e,entry:t}),s=new Ni({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}=ci(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=ip(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 xp(){return typeof FEDERATION_BUILD_IDENTIFIER<"u"?FEDERATION_BUILD_IDENTIFIER:""}function wp(e,t){const r=xp();return Me.__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 kp(e){const t=new(pd()||Ai)({id:`${e.name}@${e.version||Date.now()}`,...e});return dd(t),t}var Ve=null;function Np(e){const t=wp(e.name,e.version),r={...e,id:e.id||""};return t?(t.initOptions(r),Ve||(Ve=t),t):(Ve=kp(r),Ve)}function Sp(...e){return $e(Ve,Po,Be),Ve.loadRemote.apply(Ve,e)}function Cp(...e){return $e(Ve,Po,Be),Ve.registerRemotes.apply(Ve,e)}function Mp(){return Ve}fd(Ai);function Gt(e){const t=(typeof globalThis<"u"?globalThis:void 0)?.[e];return t&&typeof t=="object"?t:{}}var Ep={singleton:!0,requiredVersion:!1,eager:!0},Ge=e=>({version:"0.0.0",scope:"default",lib:e,shareConfig:Ep}),fs="__mf_module_cache__";function Ap(){const e=globalThis,t=e[fs];if(t&&typeof t=="object"){const n=t;return n.share??={},n.remote??={},n}const r={share:{},remote:{}};return e[fs]=r,r}function Pp(){const e=Ap();e.share.react??=la,e.share["react-dom"]??=ua,e.share["react-dom/client"]??=da,e.share["react/jsx-runtime"]??=ca,e.share["@tanstack/react-query"]??=fa,e.share["@trpc/client"]??=ga,e.share["@trpc/react-query"]??=ba,e.share["react-konva"]??=va,e.share.konva??=wa,e.share["@camstack/ui-library"]??=Gt("__camstackUiLibrary"),e.share["@camstack/sdk"]??=Gt("__camstackSdk"),e.share["@camstack/types"]??=Gt("__camstackTypes")}function Rp(){Pp(),Mp()===null&&Np({name:"admin_ui_host",remotes:[],shared:{react:Ge(()=>la),"react-dom":Ge(()=>ua),"react-dom/client":Ge(()=>da),"react/jsx-runtime":Ge(()=>ca),"@tanstack/react-query":Ge(()=>fa),"@trpc/client":Ge(()=>ga),"@trpc/react-query":Ge(()=>ba),"react-konva":Ge(()=>va),konva:Ge(()=>wa),"@camstack/ui-library":Ge(()=>Gt("__camstackUiLibrary")),"@camstack/sdk":Ge(()=>Gt("__camstackSdk")),"@camstack/types":Ge(()=>Gt("__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 Pi=(...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 _p=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 Ip=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 ms=e=>{const t=Ip(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 Tp={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 Dp=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 Lp=De(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:i,...c},l)=>ur("svg",{ref:l,...Tp,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Pi("lucide",s),...!a&&!Dp(c)&&{"aria-hidden":"true"},...c},[...i.map(([u,d])=>ur(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 G=(e,t)=>{const r=De(({className:n,...s},a)=>ur(Lp,{ref:a,iconNode:t,className:Pi(`lucide-${_p(ms(e))}`,`lucide-${e}`,n),...s}));return r.displayName=ms(e),r},ut=G("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"}]]),Op=G("arrow-down-to-line",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]),$p=G("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]),Bp=G("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Fp=G("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),zp=G("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"}]]),Gp=G("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),Qp=G("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"}]]),jp=G("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"}]]),Up=G("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"}]]),Ri=G("battery",[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]]),Hp=G("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"}]]),sn=G("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"}]]),Vp=G("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"}]]),Ro=G("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"}]]),Wp=G("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"}]]),qt=G("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]),gt=G("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),qp=G("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),bt=G("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),Kp=G("chevrons-down-up",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]),Zp=G("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),Kt=G("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"}]]),Yp=G("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"}]]),Xp=G("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Jp=G("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),ef=G("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"}]]),tf=G("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),_i=G("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"}]]),rf=G("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"}]]),nf=G("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"}]]),vt=G("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"}]]),of=G("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"}]]),_o=G("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"}]]),sf=G("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"}]]),Ii=G("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"}]]),Zn=G("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=G("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"}]]),Di=G("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"}]]),Io=G("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"}]]),Zt=G("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"}]]),Li=G("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"}]]),af=G("gamepad-2",[["line",{x1:"6",x2:"10",y1:"11",y2:"11",key:"1gktln"}],["line",{x1:"8",x2:"8",y1:"9",y2:"13",key:"qnk9ow"}],["line",{x1:"15",x2:"15.01",y1:"12",y2:"12",key:"krot7o"}],["line",{x1:"18",x2:"18.01",y1:"10",y2:"10",key:"1lcuu1"}],["path",{d:"M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z",key:"mfqc10"}]]),lf=G("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"}]]),cf=G("hexagon",[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]]),Oi=G("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"}]]),uf=G("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"}]]),df=G("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"}]]),pf=G("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),ff=G("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"}]]),$i=G("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=G("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),mf=G("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"}]]),hs=G("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"}]]),hf=G("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),Bi=G("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"}]]),gs=G("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"}]]),Fi=G("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),To=G("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"}]]),gf=G("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"}]]),Yn=G("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"}]]),bf=G("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"}]]),Xn=G("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"}]]),Yt=G("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),vf=G("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"}]]),yf=G("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"}]]),xf=G("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"}]]),zi=G("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"}]]),wf=G("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"}]]),an=G("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"}]]),Gi=G("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"}]]),Qi=G("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"}]]),kf=G("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"}]]),Nf=G("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"}]]),Sf=G("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"}]]),hr=G("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),Cf=G("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"}]]),Jn=G("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"}]]),Mf=G("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"}]]),Ef=G("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"}]]),Af=G("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"}]]),eo=G("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),Pf=G("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"}]]),ji=G("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"}]]),Rf=G("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"}]]),bs=G("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"}]]),_f=G("thermometer",[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]),If=G("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),Xe=G("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"}]]),Tf=G("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),Df=G("trending-down",[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]]),Xt=G("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"}]]),Lf=G("unlink-2",[["path",{d:"M15 7h2a5 5 0 0 1 0 10h-2m-6 0H7A5 5 0 0 1 7 7h2",key:"1re2ne"}]]),Ui=G("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"}]]),Of=G("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"}]]),Hi=G("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"}]]),Do=G("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"}]]),Re=G("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),vs=G("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"}]]),$f=G("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"}]]),Bf=G("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"}]]),m0={frigate:Ef,scrypted:Mf,reolink:wf,homeAssistant:Oi,rtsp:Wp},h0={online:Xp,offline:rf,degraded:Kt,unknown:_i},ys=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,xs=Aa,At=(e,t)=>r=>{var n;if(t?.variants==null)return xs(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=ys(u)||ys(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 xs(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)},Ff=At("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"}}),St=De(({className:e,variant:t,size:r,...n},s)=>o("button",{ref:s,className:A(Ff({variant:t,size:r}),e),...n}));St.displayName="Button";var zf=At("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"}}),Vi=De(({className:e,variant:t,size:r,icon:n,...s},a)=>o("button",{ref:a,className:A(zf({variant:t,size:r}),e),...s,children:o(n,{className:"h-4 w-4"})}));Vi.displayName="IconButton";var Gf=At("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"}}),Qt=De(({className:e,variant:t,style:r,...n},s)=>o("span",{ref:s,className:A(Gf({variant:t,styleVariant:r}),e),...n}));Qt.displayName="Badge";var Qf=At("rounded-lg p-3",{variants:{variant:{flat:"bg-surface",bordered:"bg-surface border border-border"}},defaultVariants:{variant:"bordered"}}),Wi=De(({className:e,variant:t,...r},n)=>o("div",{ref:n,className:A(Qf({variant:t}),e),...r}));Wi.displayName="Card";function jf({expanded:e,onExpandedChange:t,header:r,children:n,dimmed:s=!1,hideChevron:a=!1,className:i}){return m("div",{className:A("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(gt,{className:"h-4 w-4"}):o(bt,{className:"h-4 w-4"})}),r]}),e&&n&&o("div",{className:"border-t border-border px-3 py-3",children:n})]})}var qi=De(({className:e,...t},r)=>o("label",{ref:r,className:A("text-[10px] uppercase tracking-wider text-foreground-muted font-medium",e),...t}));qi.displayName="Label";var Uf=At("",{variants:{orientation:{horizontal:"h-px w-full bg-border-subtle",vertical:"w-px h-full bg-border-subtle"}},defaultVariants:{orientation:"horizontal"}}),Ki=De(({className:e,orientation:t,...r},n)=>o("div",{ref:n,role:"separator",className:A(Uf({orientation:t}),e),...r}));Ki.displayName="Separator";var Hf=De(({className:e,...t},r)=>o("div",{ref:r,className:A("animate-pulse bg-surface-hover rounded-md h-4 w-full",e),...t}));Hf.displayName="Skeleton";var ws=At("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"}}),to=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:A(ws({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:A(ws({state:t}),e),...s}));to.displayName="Input";var en=De(({className:e,options:t,...r},n)=>m("div",{className:"relative w-full",children:[o("select",{ref:n,className:A("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(gt,{className:"h-3.5 w-3.5"})})]}));en.displayName="Select";var Vf=De(({className:e,...t},r)=>o("input",{ref:r,type:"checkbox",className:A("w-3.5 h-3.5 rounded-sm border border-border accent-primary",e),...t}));Vf.displayName="Checkbox";var Wf=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:A("inline-flex items-center gap-2",e),...s,children:[o("span",{className:A("w-8 h-4 rounded-full transition-colors",t?"bg-primary":"bg-surface-hover"),children:o("span",{className:A("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})]}));Wf.displayName="Switch";var Zi=st(null);function Yi(){const e=Pe(Zi);if(!e)throw new Error("Dialog compound components must be used within <Dialog>");return e}function qf({children:e,open:t,onOpenChange:r}){const[n,s]=M(!1),a=t??n,i=Ct(),c=I(l=>{r?.(l),t===void 0&&s(l)},[t,r]);return o(Zi.Provider,{value:{open:a,setOpen:c,contentId:i},children:e})}function g0({children:e,...t}){const{setOpen:r}=Yi();return o("button",{type:"button",onClick:()=>r(!0),...t,children:e})}var Kf=At("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"}}),Xi=De(({className:e,width:t,children:r,...n},s)=>{const{open:a,setOpen:i,contentId:c}=Yi(),l=J(null),u=s??l;Z(()=>{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:A(Kf({width:t}),"w-full",e),onClick:d,onClose:()=>i(!1),...n,children:r})});Xi.displayName="DialogContent";function Zf({className:e,...t}){return o("div",{className:A("flex flex-col gap-1 mb-3",e),...t})}function Yf({className:e,...t}){return o("div",{className:A("flex justify-end gap-2 mt-4",e),...t})}function Xf({className:e,...t}){return o("h2",{className:A("text-sm font-semibold text-foreground",e),...t})}function Jf({className:e,...t}){return o("p",{className:A("text-xs text-foreground-muted",e),...t})}var Ji=st(null);function Lo(){const e=Pe(Ji);if(!e)throw new Error("Dropdown compound components must be used within <Dropdown>");return e}function b0({children:e}){const[t,r]=M(!1),n=Ct(),s=Ct(),a=J(null);return o(Ji.Provider,{value:{open:t,setOpen:r,triggerId:n,contentId:s,triggerRef:a},children:o("div",{className:"relative inline-block",children:e})})}function v0({children:e,...t}){const{open:r,setOpen:n,triggerId:s,contentId:a,triggerRef:i}=Lo();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 y0({className:e,children:t,align:r="start",offset:n=4,...s}){const{open:a,setOpen:i,contentId:c,triggerId:l,triggerRef:u}=Lo(),d=J(null),[p,h]=M(null);return Mc(()=>{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]),Z(()=>{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:yr(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:A("z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]",e),...s,children:t}),document.body)}function x0({className:e,icon:t,variant:r="default",children:n,onClick:s,...a}){const{setOpen:i}=Lo(),c=I(l=>{s?.(l),i(!1)},[s,i]);return m("button",{type:"button",role:"menuitem",className:A("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 el=st(null);function tl(){const e=Pe(el);if(!e)throw new Error("Tooltip compound components must be used within <Tooltip>");return e}function w0({children:e}){const[t,r]=M(!1),n=J(null),s=Ct(),a=()=>{n.current=setTimeout(()=>r(!0),300)},i=()=>{n.current&&clearTimeout(n.current),r(!1)};return o(el.Provider,{value:{open:t,show:a,hide:i,tooltipId:s},children:o("div",{className:"relative inline-block",children:e})})}function k0({children:e,...t}){const{show:r,hide:n,tooltipId:s,open:a}=tl();return o("div",{onMouseEnter:r,onMouseLeave:n,onFocus:r,onBlur:n,"aria-describedby":a?s:void 0,...t,children:e})}function N0({className:e,children:t,...r}){const{open:n,tooltipId:s}=tl();return o("div",{id:s,role:"tooltip",className:A("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 ks="(max-width: 767px)",Ns="(min-width: 768px) and (max-width: 1023px)";function rl(e){return t=>{const r=window.matchMedia(e);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)}}function nl(e){return()=>window.matchMedia(e).matches}function ol(){return!1}function ln(){return xo(rl(ks),nl(ks),ol)}function S0(){return xo(rl(Ns),nl(Ns),ol)}function sl({open:e,onClose:t,title:r,children:n,className:s}){return Z(()=>{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(ve,{children:[o("div",{className:A("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:A("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(Re,{className:"h-4 w-4"})})]}),o("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:n})]})]})}var al=st(null);function il(){const e=Pe(al);if(!e)throw new Error("Popover compound components must be used within <Popover>");return e}function em({children:e,open:t,onOpenChange:r}){const[n,s]=M(!1),a=t??n,i=Ct(),c=Ct(),l=I(u=>{r?.(u),t===void 0&&s(u)},[t,r]);return o(al.Provider,{value:{open:a,setOpen:l,triggerId:i,contentId:c},children:o("div",{className:"relative inline-block",children:e})})}function tm({children:e,...t}){const{open:r,setOpen:n,triggerId:s,contentId:a}=il();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 rm({className:e,children:t,...r}){const{open:n,setOpen:s,contentId:a,triggerId:i}=il(),c=ln(),l=J(null);return Z(()=>{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(sl,{open:n,onClose:()=>s(!1),children:t}):o("div",{ref:l,id:a,role:"dialog","aria-labelledby":i,className:A("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 ll=st(null);function cl(){const e=Pe(ll);if(!e)throw new Error("Tabs compound components must be used within <Tabs>");return e}function C0({value:e,onValueChange:t,defaultValue:r="",className:n,...s}){const[a,i]=M(r),c=e??a,l=I(u=>{t?.(u),e===void 0&&i(u)},[e,t]);return o(ll.Provider,{value:{value:c,setValue:l},children:o("div",{className:n,...s})})}function M0({className:e,...t}){return o("div",{role:"tablist",className:A("flex flex-row border-b border-border-subtle",e),...t})}function E0({value:e,className:t,...r}){const{value:n,setValue:s}=cl(),a=e===n;return o("button",{type:"button",role:"tab","aria-selected":a,"aria-controls":`tabpanel-${e}`,tabIndex:a?0:-1,className:A("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 A0({value:e,className:t,...r}){const{value:n}=cl();return e!==n?null:o("div",{role:"tabpanel",id:`tabpanel-${e}`,className:A("pt-3",t),...r})}var ul=De(({className:e,...t},r)=>o("div",{ref:r,className:A("overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full",e),...t}));ul.displayName="ScrollArea";function P0({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]=M({x:80+c*30,y:80+c*30}),[p,h]=M({w:n,h:s}),[g,b]=M(!1),v=J(!1),y=J(!1),x=J({x:0,y:0}),w=ln(),k=I(N=>{N.preventDefault(),v.current=!0,x.current={x:N.clientX-u.x,y:N.clientY-u.y}},[u]),S=I(N=>{N.preventDefault(),N.stopPropagation(),y.current=!0,x.current={x:N.clientX,y:N.clientY}},[]);return Z(()=>{const N=D=>{if(v.current&&d({x:D.clientX-x.current.x,y:D.clientY-x.current.y}),y.current){const C=D.clientX-x.current.x,_=D.clientY-x.current.y;x.current={x:D.clientX,y:D.clientY},h(O=>({w:Math.max(a,O.w+C),h:Math.max(i,O.h+_)}))}},E=()=>{v.current=!1,y.current=!1};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",E)}},[a,i]),w?m("div",{className:A("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(hs,{size:12}):o(gs,{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(Re,{size:12})})]})]}),!g&&o("div",{className:"flex-1 min-h-0 overflow-y-auto",children:r})]}):m("div",{className:A("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:k,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(lf,{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(hs,{size:12}):o(gs,{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(Re,{size:12})})]})]}),!g&&m("div",{className:"flex-1 min-h-0 overflow-y-auto relative",children:[r,o("div",{onMouseDown:S,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 nm({open:e,onClose:t,children:r,className:n,width:s="w-64"}){const a=J(null);return Z(()=>{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(ve,{children:[o("div",{className:A("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:A("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 R0({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(Ce.Fragment,{children:[n>0&&o(bt,{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 Ss={left:"text-left",right:"text-right",center:"text-center"};function _0({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",Ss[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",Ss[v],y?"whitespace-nowrap":""].filter(Boolean).join(" "),children:b.render(u,d)},b.key)})},p)})})]})})}function I0({open:e,onClose:t,title:r,subtitle:n,footer:s,children:a,widthClass:i="w-[360px]"}){return Z(()=>{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:A("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(Re,{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 om={inherit:"bg-muted",on:"bg-emerald-500",off:"bg-orange-500",na:"bg-gray-300 opacity-50"};function dl({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:A("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:A("w-2 h-2 rounded-full",om[c.state])},c.agentNodeId))})]}),e.children.map(c=>o(dl,{node:c,depth:t+1,selectedAddonId:r,onSelect:n,agentDots:s},c.addonId))]})}function T0({tree:e,selectedAddonId:t,onSelect:r,agentDots:n,className:s}){return o("div",{className:A("flex flex-col py-2",s),children:e.map(a=>o(dl,{node:a,depth:0,selectedAddonId:t,onSelect:r,agentDots:n},a.addonId))})}function D0(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 sm(e){return e?e.models.map(t=>({id:t.id,name:t.name})):[]}function Sn({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]=M(!1),b=sm(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(ve,{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:A("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:A("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(Cn,{label:"Inherit",active:l===null,variant:"inherit",subtext:d===void 0?void 0:d?"on":"off",onClick:()=>u(null)}),o(Cn,{label:"On",active:l===!0,variant:"on",onClick:()=>u(!0)}),o(Cn,{label:"Off",active:l===!1,variant:"off",onClick:()=>u(!1)})]})]});return o(jf,{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(ro,{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(ro,{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,w]=y.split("/");s({...e,engine:{runtime:x,backend:w,format:w==="coreml"?"coreml":"onnx"}})}}),t?.configSchema?.map(y=>o(Oo,{field:y,allFields:t.configSchema??[],step:e,disabled:i,onChange:s},y.key))]})})}function ro({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 am({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:A("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 im(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 Oo({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=im(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(ro,{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(am,{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 Cn({label:e,active:t,variant:r,subtext:n,onClick:s}){return m("button",{type:"button",onClick:s,className:A("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 pl(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 lm(e,t,r){return r?{enabled:r.enabled??t.enabled,modelId:r.modelId??t.modelId,settings:r.settings??t.settings}:t}function cm({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(Oo,{field:a,allFields:e.configSchema??[],step:pl(e,t),disabled:!1,onChange:i=>s({settings:{...i.settings}})},a.key))]})]})}function um({addon:e,agentDefault:t,agentNodeId:r,currentPatch:n,modelsForFormat:s,onChangePatch:a}){const i=lm("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:A("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(Oo,{field:b,allFields:e.configSchema??[],step:pl(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 L0(e){const{mode:t,addon:r,agentDefault:n,agentNodeId:s,currentPatch:a,onChangeAgentConfig:i,onChangePatch:c,engineFormat:l}=e,u=X(()=>r.models.filter(d=>!!d.formats[l]),[r.models,l]);return t==="agent"?o(cm,{addon:r,agentDefault:n,modelsForFormat:u,onChangeAgentConfig:i}):o(um,{addon:r,agentDefault:n,agentNodeId:s,currentPatch:a,modelsForFormat:u,onChangePatch:c})}function dm(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 Cs={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 pm({slot:e}){const t=Cs[e]??Cs.classifier;return o("span",{className:A("text-[9px] font-semibold uppercase tracking-widest leading-none",t.className),children:t.label})}var Ms="inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle";function fm({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:A(Ms,"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:A(Ms,"bg-emerald-500/10 text-emerald-500"),children:r},`out-${r}`))]})}function mm({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:A("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:A("inline-block h-3 w-3 rounded-full bg-white shadow transition-transform",e?"translate-x-3.5":"translate-x-0.5")})})}function hm(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 gm({node:e,depth:t,agents:r,getCellState:n,onCellClick:s,selectedCell:a,toggleProps:i}){return m(ve,{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(pm,{slot:e.slot}),m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("span",{className:"font-semibold truncate",children:e.addonName}),o(fm,{inputs:e.inputClasses,outputs:e.outputClasses})]})]}),i&&o("span",{className:"pl-2 pt-0.5 shrink-0",children:o(mm,{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:A("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:hm(l)},c.agentNodeId)})]})}function O0({tree:e,agents:t,getCellState:r,onCellClick:n,selectedCell:s,onToggleEnabled:a}){const i=X(()=>dm(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(gm,{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 fl=typeof globalThis<"u"?globalThis.__camstackTrpcReact:void 0,f=fl??Lc();typeof globalThis<"u"&&!fl&&(globalThis.__camstackTrpcReact=f);var $o=ht("camstack:system",null);function bm({system:e,children:t}){return o($o.Provider,{value:e,children:t})}function et(){const e=Pe($o);if(!e)throw new Error("useSystem(): no <SystemProvider> in tree");return e}function $0(){return Pe($o)}function cn(e,t){const r=et(),n=J(t);n.current=t;const[s,a]=M(r.connectionVersion);Z(()=>r.subscribeConnectionEvents((i,c)=>{i==="connected"&&a(c)}),[r]),Z(()=>r.subscribeEvent(e,i=>{n.current(i)}),[r,e,s])}function no(e){const t=J(e);return t.current=e,t}function ml(e,t){const[r,n]=M(null),s=no(t);return cn(e,a=>{const i=a.data,c=s.current;c&&!c(i)||n(i)}),r}function B0(e,t,r){const[n,s]=M(()=>new Map),a=no(t),i=no(r);return cn(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:X(()=>Array.from(n.values()),[n])}}function Bo(){const{data:e,isLoading:t}=f.nodes.topology.useQuery(void 0,{staleTime:6e4}),r=ml("cluster.topology-snapshot")?.nodes??e;return{nodes:X(()=>{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 F0({selectedNodeId:e,onSelect:t,label:r="Node",hideIcon:n=!1,alwaysShow:s=!1}){const{nodes:a}=Bo();return!s&&a.length<=1?null:m("div",{className:"flex items-center gap-1.5",children:[!n&&o(Cf,{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:A("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 vm={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 z0({status:e,showDot:t=!0,showLabel:r=!0,size:n="sm",className:s}){const a=vm[e];return m("span",{className:A("inline-flex items-center gap-1.5",n==="sm"?"text-xs":"text-sm",s),children:[t&&o("span",{className:A("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 ym={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 G0({provider:e,showLabel:t=!0,className:r}){const n=ym[e];return m("span",{className:A("inline-flex items-center gap-1.5 text-xs",r),children:[o("span",{className:A("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 xm={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 wm({children:e,variant:t="neutral",mono:r,className:n}){return o("span",{className:A("inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight",r&&"font-mono",xm[t],n),children:e})}function Q0({version:e,preRelease:t,className:r}){return o(wm,{variant:t??/-(alpha|beta|rc|dev|canary|next)/i.test(e)?"warning":"success",mono:!0,className:r,children:e})}function j0({label:e,description:t,error:r,required:n,children:s,orientation:a="vertical",className:i}){const c=a==="horizontal";return m("div",{className:A("flex gap-2",c?"flex-row items-center justify-between":"flex-col",i),children:[m("div",{className:A(c?"flex-1":""),children:[m(qi,{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:A(c?"shrink-0":""),children:s}),r&&o("p",{className:"text-danger text-xs",children:r})]})}function U0({title:e,subtitle:t,actions:r,className:n}){return m("div",{className:A("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 km({icon:e,title:t,description:r,action:n,className:s}){return m("div",{className:A("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 Nm={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 Sm({message:e,title:t,onRetry:r,action:n,variant:s="danger",className:a}){const i=Nm[s],c=s==="warning"?Xt:Kt;return m("div",{role:"alert",className:A("flex items-start gap-2.5 rounded border px-3 py-2.5",i.box,a),children:[o(c,{className:A("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:A("text-xs font-semibold",i.title),children:t}),o("div",{className:A("text-xs break-words",i.message,t?"mt-0.5":""),children:e})]}),n??(r&&m("button",{type:"button",onClick:r,className:A("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(an,{className:"h-3 w-3","aria-hidden":"true"}),"Retry"]}))]})}var hl=ht("camstack:confirm-dialog",null);function un(){const e=Pe(hl);if(!e)throw new Error("useConfirm must be used within ConfirmDialogProvider");return e.confirm}function H0({children:e}){const[t,r]=M(null),n=I(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(hl.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 V0({value:e,label:t,trend:r,className:n}){return m(Wi,{className:A("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:A("inline-flex items-center gap-0.5 text-xs font-medium",r.direction==="up"?"text-success":"text-danger"),children:[r.direction==="up"?o(Tf,{className:"h-3 w-3"}):o(Df,{className:"h-3 w-3"}),r.value,"%"]})]}),o("span",{className:"text-xs text-foreground-muted",children:t})]})}function W0({items:e,className:t}){return o("dl",{className:A("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 q0({children:e,maxHeight:t=300,className:r}){const[n,s]=M(!1),a=I(()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})},[e]);return m("div",{className:A("relative group",r),children:[o(ul,{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(Vi,{icon:n?qt:vt,"aria-label":"Copy code",variant:"ghost",size:"sm",onClick:a})})]})}function K0({filters:e,values:t,onChange:r,className:n}){const s=ln(),[a,i]=M(!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:A("flex items-center gap-2",n),children:[u&&o(to,{placeholder:u.placeholder??"Search...",value:t[u.key]??"",onChange:p=>c(u.key,p.target.value),leftSlot:o(hr,{className:"h-3 w-3 text-foreground-subtle"}),className:"flex-1"}),d&&m(ve,{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(Af,{className:"h-3.5 w-3.5"}),"Filters",l>0&&o(Qt,{variant:"info",className:"ml-1 text-[10px] px-1 py-0",children:l})]}),o(sl,{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(en,{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(Qt,{variant:g?"info":"default",className:"cursor-pointer",children:h.label})},h.value)})},p.key);default:return null}})})})]})]})}return o("div",{className:A("flex items-center gap-2 flex-wrap",n),children:e.map(u=>{switch(u.type){case"search":return o(to,{placeholder:u.placeholder??"Search...",value:t[u.key]??"",onChange:d=>c(u.key,d.target.value),leftSlot:o(hr,{className:"h-3 w-3 text-foreground-subtle"}),className:"w-48"},u.key);case"select":return o(en,{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(Qt,{variant:p?"info":"default",className:"cursor-pointer",children:d.label})},d.value)})},u.key);default:return null}})})}function Es({label:e,icon:t,href:r,badge:n,active:s=!1,className:a}){return m("a",{href:r,className:A("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(Qt,{className:"ml-auto text-[10px] px-1.5 py-0",children:n})]})}function As({logo:e,sections:t,footer:r,onNavigate:n,className:s}){return m("nav",{className:A("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:A(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(Es,{...c},c.href))})]},i))}),r&&r.length>0&&m("div",{className:"shrink-0 px-1 pb-1",children:[o(Ki,{className:"mb-1"}),o("div",{className:"flex flex-col gap-0.5",onClick:n,children:r.map(a=>o(Es,{...a},a.href))})]})]})}function Z0({sidebar:e,header:t,mobileLogo:r,mobileActions:n,children:s,className:a}){const i=ln(),[c,l]=M(!1);return m("div",{className:A("flex h-screen",a),children:[!i&&o(As,{...e,className:A("w-44",e.className)}),i&&o(nm,{open:c,onClose:()=>l(!1),width:"w-64",children:o(As,{...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(hf,{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(bt,{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 Cm={online:"bg-success",offline:"bg-danger",warning:"bg-warning",unknown:"bg-foreground-subtle"};function Y0({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:A("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:A("h-2 w-2 rounded-full shrink-0",Cm[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=A("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 X0({children:e,minCardWidth:t=220,gap:r=3,className:n}){return o("div",{className:A("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 Mm="capability.binding-changed";function Pt(e,t){const[r,n]=M(null);return Z(()=>{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:Mm},{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]),X(()=>r?Fc(e,r):null,[e,r])}function gl(e){const t=I(n=>e?e.subscribe(()=>n()):()=>{},[e]),r=I(()=>e?.value,[e]);return xo(t,r,r)}function Em(e,t,r){const n=Pt(e,t);return gl(n?r(n.state):void 0)}function wr(e){const t=Pt(e.trpc,e.deviceId),r=gl(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 J0(e){return e.parentDeviceId===null?"top-level":e.role?"accessory":"adopted"}var Am={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 Pm(e){const t=Am[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 Rm={siren:sn,floodlight:$i,spotlight:ji,"pir-sensor":zi,chime:gf,autotrack:_o,nightvision:To,"privacy-mask":Io,doorbell:Ii},_m={camera:Ro,hub:Yn,nvr:Yn,light:$i,siren:sn,switch:If,sensor:zi,thermostat:_f,button:Jp,generic:Do};function bl(e){return e.role?Rm[e.role]??Do:_m[e.type.toLowerCase()]??Ro}var vl={"native-snapshot":uf,"two-way-audio":Bi,"pan-tilt-zoom":_o,"ptz-autotrack":mf,"doorbell-button":Ii,"motion-trigger":ut,"battery-operated":Ri,rebootable:Qi},yl={"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"},Im={"native-snapshot":"snapshot",rebootable:"reboot","pan-tilt-zoom":"ptz","ptz-autotrack":"ptz-autotrack","two-way-audio":"intercom","motion-trigger":"motion-trigger"},xl=new Set(["camera","hub","nvr"]);function wl(e){return!xl.has(e.type.toLowerCase())}function Ps(e){return e.role?!0:!xl.has(e.type.toLowerCase())}function kl(e){return(e.features??[]).includes("motion-trigger")}function Tm(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 Dm({trpc:e,accessoryChildren:t,adoptedChildren:r,onNavigate:n}){return m("div",{className:"border-t border-border-subtle/50",children:[r.length>0&&o(Rs,{trpc:e,label:"Adopted devices",rows:r,onNavigate:n}),t.length>0&&o(Rs,{trpc:e,label:"Accessories",rows:t,onNavigate:n})]})}function Rs({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(Lm,{trpc:e,child:s,onNavigate:n},s.id))})]})}function Lm({trpc:e,child:t,onNavigate:r}){const n=!t.disabled,s=n&&wl(t),a=n&&kl(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(bl(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($m,{trpc:e,deviceId:t.id,features:t.features}),s&&o(Om,{trpc:e,deviceId:t.id}),o("span",{className:A("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 Om({trpc:e,deviceId:t}){const{dev:r,cap:n,slice:s,available:a}=wr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,c]=M(!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:A("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:A("absolute h-3 w-3 rounded-full transition-all",l?"bg-success":"bg-foreground-subtle"),style:u})})}function $m({trpc:e,deviceId:t,features:r}){const{dev:n,cap:s,slice:a,available:i}=wr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:r}),[c,l]=M(!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:A("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(ut,{className:"h-2.5 w-2.5"})})}var _s={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 Nl(e,t,r){const n=r?.defaultSpeed??.5,s=r?.pulseMs??250,a=r?.enabled??!0,i=Pt(e,a?t:null)?.ptz,[c,l]=M([]),[u,d]=M(null),[p,h]=M(!1),[g,b]=M(null),v=I(async()=>{if(!(!a||!i))try{l(await i.getPresets({}))}catch(w){if(Zr(w))return;b(w instanceof Error?w.message:String(w))}},[i,a]),y=I(async()=>{if(!(!a||!i))try{d(await i.getOptions({}))}catch(w){if(Zr(w))return;b(w instanceof Error?w.message:String(w))}},[i,a]);Z(()=>{v(),y()},[v,y]);const x=I(async w=>{if(!(!a||!i)){b(null),h(!0);try{return await w()}catch(k){b(k instanceof Error?k.message:String(k));return}finally{h(!1)}}},[a,i]);return{move:I(async(w,k)=>{if(!i)return;const S=_s[w],N=k??n;await x(async()=>{await i.move({pan:S.pan,tilt:S.tilt,speed:N}),await new Promise(E=>setTimeout(E,s)),await i.stop({})})},[i,n,s,x]),startContinuous:I(async(w,k)=>{if(!i)return;const S=_s[w],N=k??n;await x(()=>i.continuousMove({pan:S.pan,tilt:S.tilt,speed:N}))},[i,n,x]),stopContinuous:I(async()=>{i&&await x(()=>i.stop({}))},[i,x]),zoom:I(async(w,k)=>{if(!i)return;const S=w==="in"?1:-1,N=k??n;await x(async()=>{await i.move({zoom:S,speed:N}),await new Promise(E=>setTimeout(E,s)),await i.stop({})})},[i,n,s,x]),goHome:I(async()=>{i&&await x(()=>i.goHome({}))},[i,x]),goToPreset:I(async w=>{i&&await x(()=>i.goToPreset({presetId:w}))},[i,x]),savePreset:I(async w=>{if(i)return x(async()=>{const k=new Set(c.map(E=>Number(E.id)).filter(E=>Number.isInteger(E)&&E>=0));let S=0;for(;k.has(S);)S+=1;const N=String(S);return await i.savePreset({presetId:N,name:w}),await v(),N})},[i,c,v,x]),deletePreset:I(async w=>{i&&await x(async()=>{await i.deletePreset({presetId:w}),await v()})},[i,v,x]),presets:c,refreshPresets:v,options:u,busy:p,error:g}}function Er({direction:e,icon:t,disabled:r,className:n,variant:s,onMove:a,onStart:i,onStop:c}){const[l,u]=M(null),[d,p]=M(!1),h=I(x=>{if(r)return;x.currentTarget.setPointerCapture(x.pointerId),u(Date.now()),p(!1);const w=setTimeout(()=>{p(!0),i(e)},250);x.currentTarget.dataset.timer=String(w)},[e,r,i]),g=I(x=>{const w=Number(x.currentTarget.dataset.timer);w&&clearTimeout(w),x.currentTarget.dataset.timer="",d?c():l!==null&&a(e),u(null),p(!1)},[d,e,a,c,l]),b=I(x=>{const w=Number(x.currentTarget.dataset.timer);w&&clearTimeout(w),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:A("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 Sl({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,w=un(),[k,S]=M(!1),[N,E]=M(""),D=(r??b.length>0)&&b.length>0,C=t==="panel",_=C&&(v?.supportsPresets??!1),O=v?.maxPresets!==void 0&&b.length>=v.maxPresets,ae=I(async()=>{const T=N.trim();!T||y||O||await h(T)!==void 0&&E("")},[N,y,O,h]),de=I(async(T,L)=>{await w({title:"Delete preset",message:`Delete PTZ preset "${L}"? This removes it from the camera.`,confirmLabel:"Delete",variant:"danger"})&&await g(T)},[w,g]),le=C?"flex flex-col items-stretch gap-2 w-full h-full p-3":"pointer-events-auto absolute top-3 right-3 z-10 flex flex-col items-end gap-2",W=A(C?"flex items-center gap-3 rounded-lg p-2":"flex items-center gap-2 rounded-lg border border-white/30 bg-zinc-900/90 backdrop-blur-md p-2 shadow-lg shadow-black/40",y&&"ring-1 ring-primary/40"),V=C?"h-9 w-9":"h-7 w-7",Y=C?"h-4 w-4":"h-3.5 w-3.5",K=C?"text-foreground hover:bg-surface-hover":"text-white hover:bg-white/15",R=C?"h-12 w-px bg-border mx-1":"h-12 w-px bg-white/15 mx-1";return m("div",{className:A(le,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:A(W,C&&"justify-center"),children:[m("div",{className:"grid grid-cols-3 gap-0.5",children:[o("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),o(Er,{direction:"up",icon:Gp,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),o(Er,{direction:"left",icon:Bp,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),o(Er,{direction:"right",icon:Fp,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"}),o(Er,{direction:"down",icon:$p,variant:t,onMove:i,onStart:c,onStop:l}),o("span",{"aria-hidden":!0,className:C?"h-9 w-9":"h-7 w-7"})]}),(n||s)&&o("div",{className:R}),m("div",{className:"flex flex-col gap-0.5",children:[n&&m(ve,{children:[o("button",{type:"button",onClick:()=>u("in"),disabled:y,title:"Zoom in",className:A("flex items-center justify-center rounded disabled:opacity-40",V,K),children:o($f,{className:Y})}),o("button",{type:"button",onClick:()=>u("out"),disabled:y,title:"Zoom out",className:A("flex items-center justify-center rounded disabled:opacity-40",V,K),children:o(Bf,{className:Y})})]}),s&&o("button",{type:"button",onClick:()=>d(),disabled:y,title:"Go home",className:A("flex items-center justify-center rounded disabled:opacity-40",V,K),children:o(Oi,{className:Y})})]}),D&&m("div",{className:"relative",children:[m("button",{type:"button",onClick:()=>S(T=>!T),disabled:y,className:A("flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40",C?"h-9 text-foreground hover:bg-surface-hover":"h-7 text-white hover:bg-white/15"),title:"Presets",children:["Presets",o(gt,{className:A("h-3 w-3 transition-transform",k&&"rotate-180")})]}),k&&o("div",{className:A("absolute right-0 top-full mt-1 min-w-[140px] rounded-lg shadow-xl py-1 z-20",C?"bg-surface border border-border":"border border-white/30 bg-zinc-900/95 backdrop-blur-md"),children:b.map(T=>m("div",{className:A("group flex items-center",C?"hover:bg-surface-hover":"hover:bg-white/15"),children:[o("button",{type:"button",onClick:()=>{p(T.id),S(!1)},disabled:y,className:A("flex-1 px-3 py-1.5 text-left text-[10px] disabled:opacity-40",C?"text-foreground":"text-white"),children:T.name||T.id}),_&&o("button",{type:"button",onClick:()=>void de(T.id,T.name||T.id),disabled:y,title:`Delete preset ${T.name||T.id}`,className:A("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(Re,{className:"h-3 w-3"})})]},T.id))})]})]}),_&&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:N,onChange:T=>E(T.target.value),onKeyDown:T=>{T.key==="Enter"&&ae()},disabled:y||O,placeholder:"New preset name",maxLength:64,className:A("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||O||N.trim().length===0,title:O?`Camera preset limit reached (${v?.maxPresets})`:"Save current position as a new preset",className:A("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(Yt,{className:"h-3 w-3"}),"Save current position"]})]}),O&&m("span",{className:"text-[10px] text-foreground-subtle",children:["Camera preset limit reached (",v?.maxPresets,"). Delete a preset to add a new one."]})]})]})}function Cl({trpc:e,device:t,flags:r}){if(t.disabled)return null;const n=r.showSwitchToggle&&wl(t),s=kl(t),a=(t.features??[]).includes("rebootable"),i=(t.features??[]).includes("pan-tilt-zoom");return m(ve,{children:[s&&o(Fm,{trpc:e,deviceId:t.id,features:t.features}),n&&o(Bm,{trpc:e,deviceId:t.id}),i&&o(Qm,{trpc:e,deviceId:t.id}),a&&o(zm,{trpc:e,deviceId:t.id})]})}function Bm({trpc:e,deviceId:t}){const{dev:r,cap:n,slice:s,available:a}=wr({trpc:e,deviceId:t,cap:p=>p.switch,slice:p=>p.state.switch}),[i,c]=M(!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:A("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:A("absolute h-3 w-3 rounded-full transition-all",l?"bg-success":"bg-foreground-subtle"),style:u})})}function Fm({trpc:e,deviceId:t,features:r}){const{dev:n,cap:s,slice:a,available:i}=wr({trpc:e,deviceId:t,cap:p=>p.motionTrigger,slice:p=>p.state.motionTrigger,requireFeature:"motion-trigger",deviceFeatures:r}),[c,l]=M(!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:A("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(ut,{className:"h-2.5 w-2.5"})})}var Mn=168,Ml=4;function zm({trpc:e,deviceId:t}){const{dev:r,cap:n}=wr({trpc:e,deviceId:t,cap:y=>y.reboot,slice:()=>{}}),s=J(null),a=J(null),[i,c]=M(null),[l,u]=M(!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(),w=x.right-Mn,k=Math.max(8,Math.min(w,window.innerWidth-Mn-8));c({top:x.bottom+Ml,left:k})};if(Z(()=>{if(!p)return;const y=w=>{const k=s.current,S=a.current,N=w.target;N!==null&&(k&&k.contains(N)||S&&S.contains(N)||h())},x=w=>{w.key==="Escape"&&(w.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(ve,{children:[o("button",{ref:s,type:"button",onClick:b,disabled:l||!d,className:A("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&&yr(o("div",{ref:a,role:"menu",style:{position:"fixed",top:i.top,left:i.left,width:Mn},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:A("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(Qi,{className:"h-3 w-3 shrink-0 text-foreground-subtle"}),o("span",{children:"Reboot device"})]})}),document.body)]})}var Gm=300;function Qm({trpc:e,deviceId:t}){const r=J(null),n=J(null),[s,a]=M(null),i=s!==null,c=Nl(e,t,{enabled:i}),l=()=>a(null),u=()=>{const p=r.current;if(!p)return;const h=p.getBoundingClientRect(),g=8,b=Math.min(Gm,window.innerWidth-g*2),v=Math.max(g,Math.min(h.right-b,window.innerWidth-b-g)),y=h.bottom+Ml;a({top:y,left:v,width:b,maxHeight:Math.max(160,window.innerHeight-y-g)})};return Z(()=>{if(!i)return;const p=g=>{const b=r.current,v=n.current,y=g.target;y!==null&&(b&&b.contains(y)||v&&v.contains(y)||l())},h=g=>{g.key==="Escape"&&(g.stopPropagation(),l())};return document.addEventListener("mousedown",p),document.addEventListener("touchstart",p),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("touchstart",p),document.removeEventListener("keydown",h)}},[i]),m(ve,{children:[o("button",{ref:r,type:"button",onClick:p=>{p.stopPropagation(),i?l():u()},className:A("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",i&&"bg-surface-hover text-foreground"),title:"PTZ controls","aria-label":"PTZ controls","aria-haspopup":"dialog","aria-expanded":i,children:o(af,{className:"h-3 w-3"})}),s&&yr(o("div",{ref:n,style:{position:"fixed",top:s.top,left:s.left,width:s.width,maxHeight:s.maxHeight},className:"z-[9999] overflow-y-auto rounded-lg border border-border bg-surface shadow-lg shadow-black/30",onClick:p=>p.stopPropagation(),children:o(Sl,{mode:"panel",controls:c})}),document.body)]})}var jm=Object.freeze([]);function Um(e){return e==="native"?"native":"enhanced"}function Hm(e){return e.map(t=>({kind:"marker",feature:t}))}function Vm(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=Im[a];if(i===void 0){s.push({kind:"marker",feature:a});continue}const c=r.get(i);c&&s.push({kind:Um(c.kind),feature:a,capName:i})}return s}function Wm(e,t,r){const[n,s]=M(null),[a,i]=M(!1),[c,l]=M(!0);return Z(()=>{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:jm}:c||a||!n?{loading:c,resolved:Hm(r)}:{loading:!1,resolved:Vm(r,n)}}var qm=[];function El({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??qm,u=a&&l.length>0,{resolved:d}=Wm(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(Km,{accessoryCount:n,adoptedCount:s}),p&&o(Zm,{resolved:d})]})}function Km({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 Al=240,Is=200;function Zm({resolved:e}){const t=J(null),[r,n]=M(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>=Is?c.bottom+4:c.top-Is-4,left:Math.max(8,Math.min(c.left,window.innerWidth-Al-8))})},onMouseLeave:()=>n(null),children:[e.map(i=>{const c=vl[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:yl[i.feature]??i.feature,children:o(c,{className:"h-2.5 w-2.5"})},i.feature):null}),r&&yr(o(Ym,{resolved:e,position:r}),document.body)]})}function Ym({resolved:e,position:t}){return m("div",{style:{position:"fixed",top:t.top,left:t.left,width:Al,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(Xm,{entry:r},r.feature))})]})}function Xm({entry:e}){const t=vl[e.feature],r=yl[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(Jm,{kind:e.kind})]})}function Jm({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:A("text-[8.5px] px-1 rounded",e==="native"?"bg-success/15 text-success":"bg-primary/15 text-primary"),children:e})}function Pl({device:e,variant:t,flags:r,parent:n,integrationIcon:s,hasChildren:a,expanded:i,onToggleExpand:c,onNavigateToParent:l}){const u=bl(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(gt,{className:"h-3 w-3"}):o(bt,{className:"h-3 w-3"})}):r.showChildrenAccordion?o("span",{className:"h-3.5 w-3.5 flex-shrink-0"}):null,o(u,{className:A("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:A("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:Tm(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(Yn,{className:"h-2.5 w-2.5 shrink-0"}),m("span",{className:"truncate",children:["Under: ",n.name]})]})]})]})}function eh(e,t){return Em(e,t,r=>r.battery)??null}function th(e,t){const r=Pt(e,t),n=J(!1),{data:s,isLoading:a,isFetching:i,refetch:c}=pa({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 rh(e){return e<=10?Up:e<=30?jp:e>=95?Qp:Ri}function nh(e,t){return t!=="none"?"text-emerald-400":e<=10?"text-rose-400":e<=30?"text-amber-400":"text-foreground-subtle"}function oh({status:e,variant:t="compact",className:r}){if(!e)return null;const n=rh(e.percentage),s=nh(e.percentage,e.charging),a=e.charging==="solar"?ji:e.charging==="dc"?vf:null,i=e.sleeping;return m("span",{className:A("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(To,{className:"h-3 w-3 text-blue-300"}),t==="full"&&e.charging!=="none"&&o("span",{className:"text-foreground-subtle",children:e.charging})]})}function Rl({trpc:e,device:t,status:r,enabled:n,showStatusPills:s=!1}){const a=th(e,n&&t.online?t.id:null),i=(t.features??[]).includes("battery-operated"),c=s&&i&&!t.disabled,l=eh(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(oh,{status:l}),n&&o(sh,{deviceName:t.name,snapshotUrl:a.src,status:r})]})}var En=288,Ts=196,An=8;function sh({deviceName:e,snapshotUrl:t,status:r}){const n=J(null),[s,a]=M(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+An&&h>p,b=g?d.bottom+An:d.top-Ts-An,v=d.right-En;a({top:b,left:Math.max(8,Math.min(v,window.innerWidth-En-8)),placeBelow:g})},l=()=>a(null);return m(ve,{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(Zt,{className:"h-3.5 w-3.5"})}),s&&yr(m("div",{style:{position:"fixed",top:s.top,left:s.left,width:En,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 _l({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:A("h-1.5 w-1.5 rounded-full flex-shrink-0",t),title:r})}function oo(e){const{trpc:t,device:r,parent:n,integrationIcon:s,onNavigate:a,className:i,renderRowAction:c}=e,l=Pm(e),u=e.variant??"compact",d=e.view??"card",p=!r.disabled,h=r.isCamera??r.type.toLowerCase()==="camera",g=e.children??[],b=g.filter(Ps),v=g.filter(C=>!Ps(C)),y=g.length>0,[x,w]=M(!1),k=e.expanded??x,S=e.onToggleExpand??(()=>w(C=>!C)),N=C=>{a?.(C)},E=e.indentLevel??(e.isAccessoryRow?2:0),D=p?r.online?"online":"offline":"disabled";return d==="table"?o(ih,{trpc:t,device:r,variant:u,flags:l,parent:n??null,integrationIcon:s??null,accessoryCount:b.length,adoptedCount:v.length,hasChildren:y,expanded:k,onToggleExpand:S,onNavigate:N,displayStatus:D,isCamera:h,showSnapshot:l.showSnapshot&&h,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:E,className:i,renderRowAction:c??null}):m("div",{className:A("rounded-lg border border-border bg-surface transition-colors",!p&&"opacity-60",i),children:[m("div",{onClick:()=>N(r.id),className:A("flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full",u==="minimal"?"px-2.5 py-1.5":"px-3 py-2.5"),children:[o(Pl,{device:r,variant:u,flags:l,parent:n??null,integrationIcon:s??null,hasChildren:y,expanded:k,onToggleExpand:S,onNavigateToParent:N}),o(El,{trpc:t,device:r,flags:l,accessoryCount:b.length,adoptedCount:v.length,showFeatureRow:!1}),o(Rl,{trpc:t,device:r,status:D,enabled:l.showSnapshot&&h,showStatusPills:!0}),o(Cl,{trpc:t,device:r,flags:l}),c&&o("span",{onClick:C=>C.stopPropagation(),children:c(r)}),o(_l,{status:D})]}),k&&y&&o(Dm,{trpc:t,accessoryChildren:b,adoptedChildren:v,onNavigate:N})]})}var ah={0:"pl-2",1:"pl-6",2:"pl-8"};function ih(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:w,renderRowAction:k}=e;return m("tr",{onClick:()=>h(r.id),className:A("cursor-pointer hover:bg-surface-hover transition-colors",!s.showChildrenAccordion&&"border-b border-border-subtle/40",y&&"bg-foreground-subtle/[0.03]",w),children:[o("td",{className:A("py-2 align-middle pr-2",ah[x]),children:o(Pl,{device:r,variant:n,flags:s,parent:a,integrationIcon:i,hasChildren:u,expanded:d,onToggleExpand:p,onNavigateToParent:h})}),o("td",{className:"hidden md:table-cell px-2 py-2 align-middle text-[10px] text-foreground-subtle whitespace-nowrap",children:r.type}),o("td",{className:"hidden lg:table-cell px-2 py-2 align-middle",children:o(El,{trpc:t,device:r,flags:s,accessoryCount:c,adoptedCount:l,showFeatureRow:!0})}),o("td",{className:"hidden sm:table-cell px-2 py-2 align-middle",children:o(Rl,{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(Cl,{trpc:t,device:r,flags:s}),k&&o("span",{onClick:S=>S.stopPropagation(),children:k(r)}),o(_l,{status:g})]})})]})}function lh(e,t){const[r,n]=M(e);return Z(()=>{const s=setTimeout(()=>n(e),t);return()=>clearTimeout(s)},[e,t]),r}var ch=new Set(["hub","nvr"]);function uh(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(ch.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 Ds=2;function dh(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-Ds),s=Math.min(t-1,e+Ds);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 ph({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=dh(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:A("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(qp,{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:A("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:A("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(bt,{className:"h-3 w-3"})})]})]})}function fh({view:e,onViewChange:t,types:r,currentType:n,onTypeChange:s,addons:a,selectedAddons:i,onAddonsChange: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:A("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(ff,{className:"h-3.5 w-3.5"})}),o("button",{type:"button",onClick:()=>t("table"),className:A("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(Rf,{className:"h-3.5 w-3.5"})})]}),r&&r.length>0&&m(ve,{children:[o(hh,{children:"Type"}),o(Ls,{active:n===null,onClick:()=>s(null),children:"All"}),r.map(u=>o(Ls,{active:n===u,onClick:()=>s(n===u?null:u),children:gh(u)},u))]}),!l&&a&&a.length>0&&o(mh,{addons:a,selected:i,onChange:c})]})}function mh({addons:e,selected:t,onChange:r}){const[n,s]=M(!1),a=J(null);Z(()=>{if(!n)return;const u=p=>{const h=p.target;h&&a.current&&!a.current.contains(h)&&s(!1)},d=p=>{p.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",u),document.addEventListener("touchstart",u),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("touchstart",u),document.removeEventListener("keydown",d)}},[n]);const i=new Set(t),c=t.length,l=u=>{const d=new Set(i);d.has(u)?d.delete(u):d.add(u),r(e.filter(p=>d.has(p.id)).map(p=>p.id))};return m("div",{ref:a,className:"relative",children:[m("button",{type:"button",onClick:()=>s(u=>!u),className:A("inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors",c>0?"border-primary/40 bg-primary/15 text-primary":"border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover"),"aria-haspopup":"listbox","aria-expanded":n,children:[m("span",{children:["Integration",c>0?` · ${String(c)}`:""]}),o(gt,{className:A("h-3 w-3 transition-transform",n&&"rotate-180")})]}),n&&m("div",{role:"listbox",className:"absolute left-0 top-full mt-1 z-30 min-w-[180px] max-h-72 overflow-y-auto rounded-lg border border-border bg-surface shadow-xl py-1",children:[c>0&&o("button",{type:"button",onClick:()=>r([]),className:"flex w-full items-center px-3 py-1.5 text-left text-[10.5px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground",children:"Clear selection"}),e.map(u=>{const d=i.has(u.id);return m("button",{type:"button",role:"option","aria-selected":d,onClick:()=>l(u.id),className:A("flex w-full items-center gap-2 px-3 py-1.5 text-left text-[10.5px] transition-colors",d?"text-primary":"text-foreground hover:bg-surface-hover"),children:[o("span",{className:A("flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border",d?"border-primary bg-primary/20":"border-border"),children:d&&o(qt,{className:"h-2.5 w-2.5"})}),u.icon&&o("span",{className:"inline-flex items-center",children:u.icon}),o("span",{className:"truncate",children:u.name})]},u.id)})]})]})}function hh({children:e}){return o("span",{className:"text-[10px] font-medium uppercase tracking-wider text-foreground-subtle ml-1",children:e})}function Ls({active:e,icon:t,onClick:r,children:n}){return m("button",{type:"button",onClick:r,className:A("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:n})]})}function gh(e){return e.length===0?e:e[0].toUpperCase()+e.slice(1)}function bh({variant:e,onClearFilters:t}){return m("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o(df,{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 vh(e){return e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0):[]}function Ye(e,t){if(e==="root")return t==="addons"?"addon":t;switch(t){case"view":return"deviceView";case"page":return"devicePage";case"type":return"deviceType";case"q":return"deviceQ";case"addons":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 yh(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function $s(e,t,r){const n=new URLSearchParams(window.location.search),s=n.get(Ye(e,"view")),a=s==="cards"||s==="table"?s:r.view??t,i=n.get(Ye(e,"page")),c=i?parseInt(i,10):1;return{view:a,page:Number.isFinite(c)&&c>=1?c:1,addons:vh(n.get(Ye(e,"addons"))??r.addon??null),type:n.get(Ye(e,"type"))??r.type??null,q:n.get(Ye(e,"q"))??r.q??""}}function xh(e,t,r){const n=new URLSearchParams(window.location.search),s=(c,l)=>{l===null||l===""?n.delete(c):n.set(c,l)};s(Ye(e,"view"),t.view===r?null:t.view),s(Ye(e,"page"),t.page===1?null:String(t.page)),s(Ye(e,"addons"),t.addons.length>0?t.addons.join(","):null),s(Ye(e,"type"),t.type),s(Ye(e,"q"),t.q||null);const a=n.toString(),i=a?`${window.location.pathname}?${a}`:window.location.pathname;window.history.replaceState(null,"",i)}function wh(e){const{scope:t,defaultView:r,lsKey:n}=e,[s,a]=M(()=>$s(t,r,Os(n))),i=J(s);i.current=s,Z(()=>{const l=()=>{const u=$s(t,r,Os(n));i.current=u,a(u)};return window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)},[t,r,n]);const c=I(l=>{const u=l(i.current);i.current=u,a(u),xh(t,u,r),yh(n,{view:u.view,addon:u.addons.length>0?u.addons.join(","):null,type:u.type,q:u.q})},[t,r,n]);return{state:s,setView:I(l=>c(u=>({...u,view:l})),[c]),setPage:I(l=>c(u=>({...u,page:l})),[c]),setAddons:I(l=>c(u=>({...u,addons:l,page:1})),[c]),setType:I(l=>c(u=>({...u,type:l,page:1})),[c]),setQ:I(l=>c(u=>({...u,q:l,page:1})),[c]),clearFilters:I(()=>c(l=>({...l,addons:[],type:null,q:"",page:1})),[c])}}var kh={cards:24,table:50};function Nh(e){const{devices:t,trpc:r,defaultView:n="table",filters:s,forceAddon:a,resolveIntegrationIcon:i,resolveParent:c,onNavigate:l,pageSize:u=kh,urlScope:d="root",lsKey:p=d==="root"?"devices":"integrations:nested",renderRowAction:h}=e,g=wh({scope:d,defaultView:n,lsKey:p}),b=g.state.view,v=b==="cards"?u.cards:u.table,[y,x]=M(g.state.q),w=lh(y,300);Z(()=>{w!==g.state.q&&g.setQ(w)},[w]);const k=X(()=>a!==void 0?[a]:g.state.addons,[a,g.state.addons]),S=X(()=>{const W=g.state.q.toLowerCase().trim(),V=k.length>0?new Set(k):null;return t.filter(Y=>!(V&&!V.has(Y.addonId)||g.state.type&&Y.type!==g.state.type||W&&!Y.name.toLowerCase().includes(W)&&!Y.stableId.toLowerCase().includes(W)))},[t,k,g.state.type,g.state.q]),N=X(()=>uh(S),[S]),E=X(()=>{if(g.state.q.trim()==="")return new Set;const W=g.state.q.toLowerCase().trim(),V=new Set;for(const[Y,K]of N.accessoriesByParent.entries())K.some(R=>R.name.toLowerCase().includes(W)||R.stableId.toLowerCase().includes(W))&&V.add(Y);return V},[N.accessoriesByParent,g.state.q]),D=N.topLevel.length,C=Math.max(1,Math.ceil(D/v)),_=Math.min(g.state.page,C),O=(_-1)*v,ae=N.topLevel.slice(O,O+v);Z(()=>{_!==g.state.page&&g.setPage(_)},[_]),Ph();const de=k.length>0||g.state.type!==null||g.state.q!=="",le=D===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(fh,{view:b,onViewChange:g.setView,types:s?.types,currentType:g.state.type,onTypeChange:g.setType,addons:s?.addons,selectedAddons:g.state.addons,onAddonsChange:g.setAddons,hideAddons:a!==void 0}),m("div",{className:"relative",children:[o(hr,{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:y,onChange:W=>x(W.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"})]})]}),le?o(bh,{variant:de?"filtered":"nofilter",onClearFilters:de?g.clearFilters:void 0}):b==="cards"?o(Sh,{rows:ae,accessoriesByParent:N.accessoriesByParent,trpc:r,resolveIntegrationIcon:i??null,resolveParent:c??null,onNavigate:l??null,renderRowAction:h??null}):o(Eh,{rows:ae,accessoriesByParent:N.accessoriesByParent,autoExpandedParents:E,devices:S,trpc:r,resolveIntegrationIcon:i??null,resolveParent:c??null,onNavigate:l??null,renderRowAction:h??null}),o(ph,{currentPage:_,totalItems:D,pageSize:v,onPageChange:g.setPage}),a===void 0&&de&&D>0&&m("p",{className:"text-[11px] text-foreground-subtle",children:["Showing ",D," of ",t.length," devices",k.length>0&&m(ve,{children:[" ","· filtered by"," ",o("strong",{className:"text-primary",children:k.map(W=>s?.addons?.find(V=>V.id===W)?.name??W).join(", ")})]})]})]})}function Sh({rows:e,accessoriesByParent:t,trpc:r,resolveIntegrationIcon:n,resolveParent:s,onNavigate:a,renderRowAction:i}){return o("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:e.map(c=>{const l=t.get(c.id)??[];return o(oo,{trpc:r,device:c,view:"card",integrationIcon:n?.(c.addonId)??null,parent:c.parentDeviceId!==null?s?.(c.parentDeviceId)??null:null,children:l,onNavigate:a??void 0,renderRowAction:i??void 0},c.id)})})}var Ch=new Set(["hub","nvr"]);function Mh(e,t){return e.parentDeviceId===null||t===null?0:Ch.has(t.toLowerCase())?1:0}function Eh({rows:e,accessoriesByParent:t,autoExpandedParents:r,devices:n,trpc:s,resolveIntegrationIcon:a,resolveParent:i,onNavigate:c,renderRowAction:l}){const u=X(()=>{const d=new Map;for(const p of n)d.set(p.id,p.type);return d},[n]);return o("div",{className:"rounded-lg border border-border bg-surface overflow-x-auto",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:"hidden md:table-cell text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24",children:"Type"}),o("th",{className:"hidden lg:table-cell text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32",children:"Features"}),o("th",{className:"hidden sm:table-cell 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(d=>{const p=t.get(d.id)??[],h=p.length>0,g=r.has(d.id),b=d.parentDeviceId!==null?i?.(d.parentDeviceId)??null:null,v=d.parentDeviceId!==null?u.get(d.parentDeviceId)??null:null;return o(Ah,{parent:d,accessories:p,hasAccessories:h,forceExpanded:g,trpc:s,integrationIcon:a?.(d.addonId)??null,parentRowParent:b,indentLevel:Mh(d,v),onNavigate:c??null,renderRowAction:l??null},d.id)})})]})})}function Ah({parent:e,accessories:t,hasAccessories:r,forceExpanded:n,trpc:s,integrationIcon:a,parentRowParent:i,indentLevel:c,onNavigate:l,renderRowAction:u}){const[d,p]=M(n),h=J(n);return Z(()=>{h.current!==n&&(p(n),h.current=n)},[n]),m(ve,{children:[o(oo,{trpc:s,device:e,view:"table",integrationIcon:a,parent:i,children:t,onNavigate:l??void 0,showChildrenAccordion:r,expanded:d,onToggleExpand:()=>p(b=>!b),indentLevel:c,renderRowAction:u??void 0}),r&&d&&t.map(b=>o(oo,{trpc:s,device:b,view:"table",integrationIcon:null,parent:null,isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:l??void 0},b.id))]})}function Ph(){xr()}function ex({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(of,{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(Pf,{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 Rh(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 _h(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 Pn(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function Rn({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(tf,{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 tx({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:w=!1}){const k=z=>({toggleMode:b,hideModelAndSettings:w,...b==="threeState"?{overrideState:v[z]!==void 0?v[z]:null,onOverrideChange:y?B=>y(z,B):void 0,inheritedEnabled:x[z]}:{}}),S=X(()=>new Set(d),[d]),N=X(()=>_h(e),[e]),[E,D]=M([]),C=s?JSON.stringify(t)!==JSON.stringify(n.find(z=>z.id===s)?.steps):!1;function _(z){const B=z.target.value||null;if(B){const ee=n.find(P=>P.id===B);ee&&D([...Rh(ee.steps,e).warnings])}else D([]);a(B)}function O(){s&&c(s,t)}function ae(){const z=window.prompt("Template name:");z?.trim()&&i(z.trim(),t)}function de(){if(!s)return;const z=n.find(B=>B.id===s);z&&window.confirm(`Delete template "${z.name}"?`)&&l(s)}function le(z){r(t.map(B=>B.addonId!==z.addonId?B:W(z)))}function W(z){const B=z.children.some(ee=>ee.enabled||ee.children.some(P=>P.enabled));return{...z,enabled:z.enabled||B,children:z.children.map(ee=>{const P=ee.children.some(F=>F.enabled);return{...ee,enabled:ee.enabled||P}})}}function V(z,B){const ee=Pn(B);r(t.map(P=>P.addonId!==z?P:{...P,children:[...P.children,ee]}))}function Y(z){const B=new Set;for(const ee of z){B.add(ee.addonId);for(const F of ee.children)B.add(F.addonId);const P=Y(ee.children);for(const F of P)B.add(F)}return B}const K=Y(t);function R(z){const B=N.get(z.addonId);if(!B)return[];const ee=e.slots.find(q=>q.id===B.slot)?.parentSlot==null,P=B.childSlots,F=new Set(z.children.map(q=>q.addonId)),U=[];for(const q of e.slots)if(P.includes(q.id))for(const se of q.addons){if(F.has(se.id)||S.has(se.id))continue;const te=se.inputClasses.length===0;te&&!ee||(te||se.inputClasses.some(_e=>z.outputClasses.includes(_e)))&&U.push(se)}return U}function T(z){const B=h?{...z,children:z.children.filter(P=>P.enabled).map(P=>({...P,children:P.children.filter(F=>F.enabled)}))}:z,ee=h?[]:R(B);return m("div",{className:"space-y-1.5",children:[o(Sn,{step:B,schema:N.get(B.addonId)??null,allSchemas:N,onChange:le,onDelete:u?void 0:P=>r(t.filter(F=>F.addonId!==P)),readOnly:u,...k(B.addonId)}),(B.children.length>0||ee.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"}),B.children.map(P=>{const F=R(P);return m("div",{className:"space-y-1.5",children:[o(Sn,{step:P,schema:N.get(P.addonId)??null,allSchemas:N,depth:1,onChange:U=>{le({...B,children:B.children.map(q=>q.addonId===U.addonId?U:q)})},onDelete:u?void 0:U=>{le({...B,children:B.children.filter(q=>q.addonId!==U)})},readOnly:u,...k(P.addonId)}),(P.children.length>0||F.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"}),P.children.map(U=>o(Sn,{step:U,schema:N.get(U.addonId)??null,allSchemas:N,depth:2,onChange:q=>{le({...B,children:B.children.map(se=>se.addonId===P.addonId?{...se,children:se.children.map(te=>te.addonId===q.addonId?q:te)}:se)})},onDelete:u?void 0:q=>{le({...B,children:B.children.map(se=>se.addonId===P.addonId?{...se,children:se.children.filter(te=>te.addonId!==q)}:se)})},readOnly:u,...k(U.addonId)},U.addonId)),!u&&F.map(U=>o(Rn,{addon:U,onClick:()=>{const q=Pn(U);le({...B,children:B.children.map(se=>se.addonId===P.addonId?{...se,children:[...se.children,q]}:se)})}},U.id))]})]},P.addonId)}),!u&&ee.map(P=>o(Rn,{addon:P,onClick:()=>V(B.addonId,P)},P.id))]})]},B.addonId)}const L=e.slots.filter(z=>z.parentSlot===null).sort((z,B)=>z.priority-B.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:_,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(z=>o("option",{value:z.id,children:z.name},z.id))]})}),C&&o("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0"}),o("button",{onClick:O,disabled:!s||u,title:"Save",className:A("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(kf,{className:"h-4 w-4"})}),o("button",{onClick:ae,disabled:u,title:"Save As",className:A("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(nf,{className:"h-4 w-4"})}),o("button",{onClick:de,disabled:!s||u,title:"Delete",className:A("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(Xe,{className:"h-4 w-4"})})]})}),E.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:()=>D([]),className:"text-amber-400/60 hover:text-amber-400",children:o(Re,{className:"h-3.5 w-3.5"})})]}),E.map((z,B)=>m("div",{children:["• ",z]},B))]}),L.map(z=>{const B=t.filter(q=>q.slot===z.id&&!S.has(q.addonId)),ee=h?B.filter(q=>q.enabled):B,P=h?[]:z.addons.filter(q=>!K.has(q.id)&&!S.has(q.id)),F=new Map,U=[];for(const q of ee)q.group?(F.has(q.group)||F.set(q.group,[]),F.get(q.group).push(q)):U.push(q);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: ",z.label]}),U.map(q=>T(q)),[...F.entries()].map(([q,se])=>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:q}),se.map(te=>T(te))]},q)),!u&&P.map(q=>o(Rn,{addon:q,onClick:()=>{r([...t,Pn(q)])}},q.id))]},z.id)})]})}var Ar={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"},Bs=["#ef4444","#8b5cf6","#06b6d4","#f97316","#10b981","#6366f1","#e11d48","#0891b2","#7c3aed","#059669"],rx="#f59e42";function je(e,t){if(t?.[e])return t[e];if(t?.[e.toLowerCase()])return t[e.toLowerCase()];if(Ar[e])return Ar[e];if(Ar[e.toLowerCase()])return Ar[e.toLowerCase()];let r=0;for(let n=0;n<e.length;n++)r=r*31+(e.codePointAt(n)??0)>>>0;return Bs[r%Bs.length]??"#f59e42"}function nx({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=Dh(v,x=>x.parentId??"");return o("div",{className:A("rounded-lg border border-border bg-surface overflow-hidden relative",i),style:{aspectRatio:h},children:e?m(ve,{children:[o("img",{src:e,className:"absolute inset-0 w-full h-full object-fill",alt:""}),g.map((x,w)=>x.debug?.mask&&x.debug.maskWidth&&x.debug.maskHeight?o(Ih,{mask:x.debug.mask,maskWidth:x.debug.maskWidth,maskHeight:x.debug.maskHeight,bbox:x.bbox,imageWidth:t,imageHeight:r,color:p(x.macroClass)},`mask-${w}`):null),b.map(x=>{const w=y.get(x.id)??[];return o(Fs,{detection:x,imageWidth:t,imageHeight:r,color:p(x.macroClass),showConfidence:l,borderWidth:x.debug?.mask?1:d,children:w.map(k=>o(Th,{child:k,parentBbox:x.bbox,color:p(k.macroClass),showConfidence:l},`child-${k.id}`))},`det-${x.id}`)}),v.filter(x=>!x.parentId||!b.some(w=>w.id===x.parentId)).map(x=>o(Fs,{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 Fs({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 Ih({mask:e,maskWidth:t,maskHeight:r,bbox:n,imageWidth:s,imageHeight:a,color:i}){const c=J(null);return Z(()=>{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 w=x<p.length?p[x]:0,k=x*4;w>0&&(v.data[k]=h,v.data[k+1]=g,v.data[k+2]=b,v.data[k+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 Th({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 Dh(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 ox({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(zs,{detection:d,children_:l.get(d.id)??[],colors:a,hiddenKeys:n,onToggleVisibility:s},d.id)),u.map(d=>o(zs,{detection:d,children_:[],colors:a,hiddenKeys:n,onToggleVisibility:s},d.id))]})]})}function zs({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($h,{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(Oh,{alternateLabels:d,colors:r}),t.length>0&&o(Lh,{items:t,colors:r,hiddenKeys:n,onToggleVisibility:s})]})}function Lh({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 Oh({alternateLabels:e,colors:t}){const[r,n]=M(!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 $h({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 sx({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 ax({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 Pr="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 ix({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:Pr,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:Pr,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:Pr,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:Pr,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 Bh=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()}},Il=class{constructor(e){this.generateIdentifier=e,this.kv=new Bh}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)}},Fh=class extends Il{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 zh(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 Gh(e,t){const r=zh(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 Wt(e,t){Object.entries(e).forEach(([r,n])=>t(n,r))}function Vr(e,t){return e.indexOf(t)!==-1}function Gs(e,t){for(let r=0;r<e.length;r++){const n=e[r];if(t(n))return n}}var Qh=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return Gh(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},jh=e=>Object.prototype.toString.call(e).slice(8,-1),Tl=e=>typeof e>"u",Uh=e=>e===null,gr=e=>typeof e!="object"||e===null||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,so=e=>gr(e)&&Object.keys(e).length===0,ft=e=>Array.isArray(e),Hh=e=>typeof e=="string",Vh=e=>typeof e=="number"&&!isNaN(e),Wh=e=>typeof e=="boolean",qh=e=>e instanceof RegExp,br=e=>e instanceof Map,vr=e=>e instanceof Set,Dl=e=>jh(e)==="Symbol",Kh=e=>e instanceof Date&&!isNaN(e.valueOf()),Ll=e=>e instanceof Error,Qs=e=>typeof e=="number"&&isNaN(e),Zh=e=>Wh(e)||Uh(e)||Tl(e)||Vh(e)||Hh(e)||Dl(e),Yh=e=>typeof e=="bigint",Xh=e=>e===1/0||e===-1/0,Jh=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),eg=e=>e instanceof URL,ao=e=>e.replace(/\\/g,"\\\\").replace(/\./g,"\\."),_n=e=>e.map(String).map(ao).join("."),ar=(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 Ze(e,t,r,n){return{isApplicable:e,annotation:t,transform:r,untransform:n}}var Ol=[Ze(Tl,"undefined",()=>null,()=>{}),Ze(Yh,"bigint",e=>e.toString(),e=>typeof BigInt<"u"?BigInt(e):(console.error("Please add a BigInt polyfill."),e)),Ze(Kh,"Date",e=>e.toISOString(),e=>new Date(e)),Ze(Ll,"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}),Ze(qh,"regexp",e=>""+e,e=>{const t=e.slice(1,e.lastIndexOf("/")),r=e.slice(e.lastIndexOf("/")+1);return new RegExp(t,r)}),Ze(vr,"set",e=>[...e.values()],e=>new Set(e)),Ze(br,"map",e=>[...e.entries()],e=>new Map(e)),Ze(e=>Qs(e)||Xh(e),"number",e=>Qs(e)?"NaN":e>0?"Infinity":"-Infinity",Number),Ze(e=>e===0&&1/e===-1/0,"number",()=>"-0",Number),Ze(eg,"URL",e=>e.toString(),e=>new URL(e))];function dn(e,t,r,n){return{isApplicable:e,annotation:t,transform:r,untransform:n}}var $l=dn((e,t)=>Dl(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}),tg=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),Bl=dn(Jh,e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{const r=tg[t[1]];if(!r)throw new Error("Trying to deserialize unknown typed array");return new r(e)});function Fl(e,t){return e?.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var zl=dn(Fl,(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)}),Gl=dn((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)}),rg=[zl,$l,Gl,Bl],js=(e,t)=>{const r=Gs(rg,s=>s.isApplicable(e,t));if(r)return{value:r.transform(e,t),type:r.annotation(e,t)};const n=Gs(Ol,s=>s.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},Ql={};Ol.forEach(e=>{Ql[e.annotation]=e});var ng=(e,t,r)=>{if(ft(t))switch(t[0]){case"symbol":return $l.untransform(e,t,r);case"class":return zl.untransform(e,t,r);case"custom":return Gl.untransform(e,t,r);case"typed-array":return Bl.untransform(e,t,r);default:throw new Error("Unknown transformation: "+t)}else{const n=Ql[t];if(!n)throw new Error("Unknown transformation: "+t);return n.untransform(e,r)}},Ot=(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 jl(e){if(Vr(e,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Vr(e,"prototype"))throw new Error("prototype is not allowed as a property");if(Vr(e,"constructor"))throw new Error("constructor is not allowed as a property")}var og=(e,t)=>{jl(t);for(let r=0;r<t.length;r++){const n=t[r];if(vr(e))e=Ot(e,+n);else if(br(e)){const s=+n,a=+t[++r]==0?"key":"value",i=Ot(e,s);switch(a){case"key":e=i;break;case"value":e=e.get(i);break}}else e=e[n]}return e},io=(e,t,r)=>{if(jl(t),t.length===0)return r(e);let n=e;for(let a=0;a<t.length-1;a++){const i=t[a];if(ft(n)){const c=+i;n=n[c]}else if(gr(n))n=n[i];else if(vr(n)){const c=+i;n=Ot(n,c)}else if(br(n)){if(a===t.length-2)break;const c=+i,l=+t[++a]==0?"key":"value",u=Ot(n,c);switch(l){case"key":n=u;break;case"value":n=n.get(u);break}}}const s=t[t.length-1];if(ft(n)?n[+s]=r(n[+s]):gr(n)&&(n[s]=r(n[s])),vr(n)){const a=Ot(n,+s),i=r(a);a!==i&&(n.delete(a),n.add(i))}if(br(n)){const a=+t[t.length-2],i=Ot(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},Ul=e=>e<1;function lo(e,t,r,n=[]){if(!e)return;const s=Ul(r);if(!ft(e)){Wt(e,(c,l)=>lo(c,t,r,[...n,...ar(l,s)]));return}const[a,i]=e;i&&Wt(i,(c,l)=>{lo(c,t,r,[...n,...ar(l,s)])}),t(a,n)}function sg(e,t,r,n){return lo(t,(s,a)=>{e=io(e,a,i=>ng(i,s,n))},r),e}function ag(e,t,r){const n=Ul(r);function s(a,i){const c=og(e,ar(i,n));a.map(l=>ar(l,n)).forEach(l=>{e=io(e,l,()=>c)})}if(ft(t)){const[a,i]=t;a.forEach(c=>{e=io(e,ar(c,n),()=>e)}),i&&Wt(i,s)}else Wt(t,s);return e}var ig=(e,t)=>gr(e)||ft(e)||br(e)||vr(e)||Ll(e)||Fl(e,t);function lg(e,t,r){const n=r.get(e);n?n.push(t):r.set(e,[t])}function cg(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(_n):r[_n(a)]=i.map(_n)}),n?so(r)?[n]:[n,r]:so(r)?void 0:r}var Hl=(e,t,r,n,s=[],a=[],i=new Map)=>{const c=Zh(e);if(!c){lg(e,s,t);const g=i.get(e);if(g)return n?{transformedValue:null}:g}if(!ig(e,r)){const g=js(e,r),b=g?{transformedValue:g.value,annotations:[g.type]}:{transformedValue:e};return c||i.set(e,b),b}if(Vr(a,e))return{transformedValue:null};const l=js(e,r),u=l?.value??e,d=ft(u)?[]:{},p={};Wt(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=Hl(g,t,r,n,[...s,b],[...a,e],i);d[b]=v.transformedValue,ft(v.annotations)?p[ao(b)]=v.annotations:gr(v.annotations)&&Wt(v.annotations,(y,x)=>{p[ao(b)+"."+x]=y})});const h=so(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 Vl(e){return Object.prototype.toString.call(e).slice(8,-1)}function Us(e){return Vl(e)==="Array"}function ug(e){if(Vl(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function dg(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 co(e,t={}){if(Us(e))return e.map(s=>co(s,t));if(!ug(e))return e;const r=Object.getOwnPropertyNames(e),n=Object.getOwnPropertySymbols(e);return[...r,...n].reduce((s,a)=>{if(a==="__proto__"||Us(t.props)&&!t.props.includes(a))return s;const i=e[a];return dg(s,a,co(i,t),e,t.nonenumerable),s},{})}var ge=class{constructor({dedupe:e=!1}={}){this.classRegistry=new Fh,this.symbolRegistry=new Il(t=>t.description??""),this.customTransformerRegistry=new Qh,this.allowedErrorProps=[],this.dedupe=e}serialize(e){const t=new Map,r=Hl(e,t,this,this.dedupe),n={json:r.transformedValue};r.annotations&&(n.meta={...n.meta,values:r.annotations});const s=cg(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:co(r);return n?.values&&(s=sg(s,n.values,n.v??0,this)),n?.referentialEqualities&&(s=ag(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)}};ge.defaultInstance=new ge;ge.serialize=ge.defaultInstance.serialize.bind(ge.defaultInstance);ge.deserialize=ge.defaultInstance.deserialize.bind(ge.defaultInstance);ge.stringify=ge.defaultInstance.stringify.bind(ge.defaultInstance);ge.parse=ge.defaultInstance.parse.bind(ge.defaultInstance);ge.registerClass=ge.defaultInstance.registerClass.bind(ge.defaultInstance);ge.registerSymbol=ge.defaultInstance.registerSymbol.bind(ge.defaultInstance);ge.registerCustom=ge.defaultInstance.registerCustom.bind(ge.defaultInstance);ge.allowErrorProps=ge.defaultInstance.allowErrorProps.bind(ge.defaultInstance);ge.serialize;ge.deserialize;ge.stringify;ge.parse;ge.registerClass;ge.registerCustom;ge.registerSymbol;ge.allowErrorProps;function pg({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 fg({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 mg({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 hg({onLogin:e,serverUrl:t,logoSrc:r,error:n,className:s}){const[a,i]=M(""),[c,l]=M(""),[u,d]=M(!1),[p,h]=M(!1),[g,b]=M(null),v=n??g,y=async x=>{if(x.preventDefault(),!p){b(null),h(!0);try{await e(a,c)}catch(w){b(w instanceof Error?w.message:"Login failed. Please try again.")}finally{h(!1)}}};return o("div",{className:A("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(fg,{className:"h-4 w-4"}):o(pg,{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(mg,{className:"h-4 w-4 animate-spin"}),p?"Logging in...":"Log in"]})]})]})})}var uo="camstack_dev_token",Wl=st(null);function lx(){const e=Pe(Wl);if(!e)throw new Error("useDevShell must be used within a DevShell");return e}function gg(){return typeof window>"u"?null:localStorage.getItem(uo)}function bg({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 vg({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 yg({children:e,serverUrl:t,title:r,token:n,onLogout:s}){const a=Xc(),i=X(()=>[Ic({condition:h=>h.type==="subscription",true:Tc({client:Dc({url:t.replace(/^http/,"ws")+"/trpc",connectionParams:()=>({token:n})}),transformer:ge}),false:ha({url:`${t}/trpc`,transformer:ge,headers:()=>({authorization:`Bearer ${n}`})})})],[t,n]),c=X(()=>ma({links:i}),[i]),l=X(()=>f.createClient({links:i}),[i]),u=X(()=>jc({serverUrl:t,token:n}),[t,n]);Z(()=>(u.init().catch(()=>{}),()=>{u.close()}),[u]);const d=X(()=>new Rc,[]),p=X(()=>({trpc:c,token:n,logout:s}),[c,n,s]);return o(bm,{system:u,children:o(f.Provider,{client:l,queryClient:d,children:o(_c,{client:d,children:o(Wl.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(bg,{className:"h-3.5 w-3.5"}):o(vg,{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 xg({children:e,serverUrl:t="https://localhost:4443",title:r}){const[n,s]=M(gg),a=I(async(c,l)=>{const u=await ma({links:[ha({url:`${t}/trpc`,transformer:ge})]}).auth.login.mutate({username:c,password:l});if(!u.token)throw new Error("No token returned");localStorage.setItem(uo,u.token),s(u.token)},[t]),i=I(()=>{localStorage.removeItem(uo),s(null)},[]);return n?o(Yo,{children:o(yg,{serverUrl:t,title:r,token:n,onLogout:i,children:e})}):o(Yo,{children:o(hg,{onLogin:a,serverUrl:t})})}function cx(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}Ac(a).render(ur(xg,{serverUrl:r,title:n,children:({trpc:i,theme:c})=>ur(e,{trpc:i,theme:{isDark:c.resolvedMode==="dark"},navigate:l=>{console.log("[dev] navigate:",l)}})}))}var ql=ht("camstack:custom-field-renderers",{});function ux({renderers:e,children:t}){return o(ql.Provider,{value:e,children:t})}function wg(e){return Pe(ql)[e]??null}var Fo=ht("camstack:device-context",null);function dx({deviceId:e,device:t,children:r}){const n={deviceId:e,device:t??null};return o(Fo.Provider,{value:n,children:r})}function kg(){return Pe(Fo)?.deviceId??null}function px(){return Pe(Fo)?.device??null}var fx=f.accessories.getStatus.useQuery,mx=f.addonPages.listPages.useQuery,Ng=f.addons.list.useQuery,hx=f.addons.getLogs.useQuery,gx=f.addons.listPackages.useQuery,bx=f.addons.installPackage.useMutation,vx=f.addons.installFromWorkspace.useMutation,yx=f.addons.isWorkspaceAvailable.useQuery,xx=f.addons.listWorkspacePackages.useQuery,wx=f.addons.uninstallPackage.useMutation,kx=f.addons.reloadPackages.useMutation,Nx=f.addons.searchAvailable.useQuery,Sx=f.addons.listUpdates.useQuery,Cx=f.addons.updatePackage.useMutation,Mx=f.addons.rollbackPackage.useMutation,Ex=f.addons.forceRefresh.useMutation,Ax=f.addons.restartServer.useMutation,Px=f.addons.getLastRestart.useQuery,Rx=f.addons.listFrameworkPackages.useQuery,_x=f.addons.listCapabilityProviders.useQuery,Ix=f.addons.setCapabilityProviderEnabled.useMutation,Tx=f.addons.updateFrameworkPackage.useMutation,Dx=f.addons.startBulkUpdate.useMutation,Lx=f.addons.getBulkUpdateState.useQuery,Ox=f.addons.cancelBulkUpdate.useMutation,$x=f.addons.listActiveBulkUpdates.useQuery,Bx=f.addons.getVersions.useQuery,Fx=f.addons.restartAddon.useMutation,zx=f.addons.retryLoad.useMutation,Gx=f.addons.getAutoUpdateSettings.useQuery,Qx=f.addons.setAutoUpdateSettings.useMutation,jx=f.addons.getAddonAutoUpdate.useQuery,Ux=f.addons.setAddonAutoUpdate.useMutation,Hx=f.addons.applyAutoUpdateToAll.useMutation,Vx=f.addons.custom.useMutation,Wx=f.addons.onAddonLogs.useSubscription,qx=f.addonSettings.getGlobalSettings.useQuery,Kx=f.addonSettings.updateGlobalSettings.useMutation,Zx=f.addonSettings.getDeviceSettings.useQuery,Yx=f.addonSettings.updateDeviceSettings.useMutation,Sg=f.addonWidgets.listWidgets.useQuery,Xx=f.alerts.emit.useMutation,Jx=f.alerts.update.useMutation,e1=f.alerts.list.useQuery,t1=f.alerts.getUnreadCount.useQuery,r1=f.alerts.markRead.useMutation,n1=f.alerts.markAllRead.useMutation,o1=f.alerts.dismiss.useMutation,s1=f.audioAnalysis.resolveDeviceSettings.useQuery,a1=f.audioAnalysis.getDeviceSettingsContribution.useQuery,i1=f.audioAnalysis.getDeviceLiveContribution.useQuery,l1=f.audioAnalysis.applyDeviceSettingsPatch.useMutation,c1=f.audioAnalyzer.analyseChunk.useMutation,u1=f.audioAnalyzer.classify.useQuery,d1=f.audioAnalyzer.isReady.useQuery,p1=f.audioAnalyzer.dispose.useMutation,f1=f.audioAnalyzer.reprobeAudioEngine.useMutation,m1=f.audioCodec.listSupportedCodecs.useQuery,h1=f.audioCodec.canHandle.useQuery,g1=f.audioCodec.createDecodeSession.useMutation,b1=f.audioCodec.createEncodeSession.useMutation,v1=f.audioCodec.closeSession.useMutation,y1=f.audioCodec.pushEncodedFrame.useMutation,x1=f.audioCodec.pullPcm.useQuery,w1=f.audioCodec.pushPcm.useMutation,k1=f.audioCodec.pullEncoded.useQuery,N1=f.audioCodec.flushEncode.useMutation,S1=f.audioCodec.listActiveSessions.useQuery,C1=f.audioMetrics.getCurrentSnapshot.useQuery,M1=f.audioMetrics.getHistory.useQuery,E1=f.backup.listDestinations.useQuery,A1=f.backup.trigger.useMutation,P1=f.backup.list.useQuery,R1=f.backup.listLocations.useQuery,_1=f.backup.getEntries.useQuery,I1=f.backup.restore.useMutation,T1=f.backup.delete.useMutation,D1=f.backup.listArchives.useQuery,L1=f.backup.upsertDestinationPolicy.useMutation,O1=f.backup.previewSchedule.useQuery,$1=f.battery.getStatus.useQuery,B1=f.brightness.setBrightness.useMutation,F1=f.brightness.getStatus.useQuery,z1=f.cameraCredentials.getCredentials.useQuery,G1=f.cameraCredentials.getStatus.useQuery,Q1=f.cameraPipelineConfig.getDeviceSettingsContribution.useQuery,j1=f.cameraPipelineConfig.getDeviceLiveContribution.useQuery,U1=f.cameraPipelineConfig.applyDeviceSettingsPatch.useMutation,H1=f.cameraStreams.getCameraStreams.useQuery,V1=f.cameraStreams.getBrokerStreams.useQuery,Cg=f.cameraStreams.getRtspEntries.useQuery,W1=f.decoder.supportsCodec.useQuery,q1=f.decoder.getInfo.useQuery,K1=f.decoder.createSession.useQuery,Z1=f.decoder.destroySession.useQuery,Y1=f.decoder.pushPacket.useQuery,X1=f.decoder.openStream.useQuery,J1=f.decoder.pullFrames.useQuery,ew=f.decoder.pullHandles.useQuery,tw=f.decoder.getFrame.useQuery,rw=f.decoder.getShmStats.useQuery,nw=f.decoder.updateConfig.useQuery,ow=f.decoder.getStats.useQuery,sw=f.decoder.listActiveSessions.useQuery,aw=f.decoder.reprobeHwaccel.useMutation,iw=f.detectionPipeline.getDeviceSettingsContribution.useQuery,lw=f.detectionPipeline.getDeviceLiveContribution.useQuery,cw=f.detectionPipeline.applyDeviceSettingsPatch.useMutation,uw=f.deviceDiscovery.listDiscovered.useQuery,dw=f.deviceDiscovery.refreshDiscovery.useMutation,pw=f.deviceDiscovery.adoptDevice.useMutation,fw=f.deviceDiscovery.releaseDevice.useMutation,mw=f.deviceDiscovery.getStatus.useQuery,Mg=f.deviceExport.getStatus.useQuery,Eg=f.deviceExport.listSupportedDeviceKinds.useQuery,Ag=f.deviceExport.listExposedDevices.useQuery,Pg=f.deviceExport.exposeDevice.useMutation,Rg=f.deviceExport.unexposeDevice.useMutation,hw=f.deviceExport.getDeviceSettingsContribution.useQuery,gw=f.deviceExport.getDeviceLiveContribution.useQuery,bw=f.deviceExport.applyDeviceSettingsPatch.useMutation,vw=f.deviceManager.allocateDeviceId.useMutation,yw=f.deviceManager.registerDevice.useMutation,xw=f.deviceManager.removeDevice.useMutation,ww=f.deviceManager.persistConfig.useMutation,kw=f.deviceManager.loadConfig.useQuery,Nw=f.deviceManager.loadRuntimeState.useQuery,Sw=f.deviceManager.loadMeta.useQuery,Cw=f.deviceManager.setName.useMutation,Mw=f.deviceManager.setLocation.useMutation,Ew=f.deviceManager.setMetadata.useMutation,Aw=f.deviceManager.listLocations.useQuery,Pw=f.deviceManager.addLocation.useMutation,Rw=f.deviceManager.removeLocation.useMutation,_w=f.deviceManager.setDisabled.useMutation,Iw=f.deviceManager.listPersistedByAddon.useQuery,Kl=f.deviceManager.listAll.useQuery,Tw=f.deviceManager.getDevice.useQuery,Dw=f.deviceManager.getChildren.useQuery,Lw=f.deviceManager.getStreamSources.useQuery,Ow=f.deviceManager.getConfigSchema.useQuery,$w=f.deviceManager.getSettingsSchema.useQuery,Bw=f.deviceManager.updateConfig.useMutation,Fw=f.deviceManager.enable.useMutation,zw=f.deviceManager.disable.useMutation,Gw=f.deviceManager.remove.useMutation,Qw=f.deviceManager.getStreamProfileMap.useQuery,jw=f.deviceManager.setStreamProfileMap.useMutation,Uw=f.deviceManager.probeStreams.useMutation,Hw=f.deviceManager.getBindings.useQuery,Vw=f.deviceManager.getAllBindings.useQuery,Ww=f.deviceManager.setWrapperActive.useMutation,qw=f.deviceManager.listWrappersForCap.useQuery,Kw=f.deviceManager.listBindableCapsForDeviceType.useQuery,Zw=f.deviceManager.getDeviceSettingsAggregate.useQuery,Yw=f.deviceManager.getDeviceLiveInfoAggregate.useQuery,Xw=f.deviceManager.getDeviceAggregate.useQuery,Jw=f.deviceManager.updateDeviceField.useMutation,ek=f.deviceManager.updateDeviceFieldsBatch.useMutation,tk=f.deviceManager.discoverDevices.useMutation,rk=f.deviceManager.adoptDevice.useMutation,nk=f.deviceManager.getCreationSchema.useQuery,ok=f.deviceManager.createDevice.useMutation,sk=f.deviceManager.testCreationField.useMutation,ak=f.deviceManager.testField.useMutation,ik=f.deviceManager.getDeviceStatusAggregate.useQuery,lk=f.deviceOps.getStreamSources.useQuery,ck=f.deviceOps.getConfigEntries.useQuery,uk=f.deviceOps.setConfig.useMutation,dk=f.deviceOps.removeDevice.useMutation,pk=f.deviceOps.getSettingsSchema.useQuery,fk=f.deviceProvider.start.useMutation,mk=f.deviceProvider.stop.useMutation,hk=f.deviceProvider.getStatus.useQuery,gk=f.deviceProvider.getDevices.useQuery,bk=f.deviceProvider.supportsDiscovery.useQuery,vk=f.deviceProvider.discoverDevices.useMutation,yk=f.deviceProvider.adoptDiscoveredDevice.useMutation,xk=f.deviceProvider.supportsManualCreation.useQuery,wk=f.deviceProvider.getChildCreationSchema.useQuery,kk=f.deviceProvider.createDevice.useMutation,Nk=f.deviceProvider.testCreationField.useMutation,Sk=f.deviceState.getSnapshot.useQuery,Ck=f.deviceState.getCapSlice.useQuery,Mk=f.deviceState.getAllSnapshots.useQuery,Ek=f.deviceState.setCapSlice.useMutation,Ak=f.deviceStatus.getStatus.useQuery,Pk=f.doorbell.getStatus.useQuery,Rk=f.events.getEvents.useQuery,_k=f.events.getEventThumbnail.useQuery,Ik=f.events.getEventClipUrl.useQuery,Tk=f.featureProbe.getStatus.useQuery,Dk=f.integrations.list.useQuery,Lk=f.integrations.get.useQuery,Ok=f.integrations.getByAddonId.useQuery,$k=f.integrations.create.useMutation,Bk=f.integrations.update.useMutation,Fk=f.integrations.delete.useMutation,zk=f.integrations.getSettings.useQuery,Gk=f.integrations.setSettings.useMutation,Qk=f.integrations.getAvailableTypes.useQuery,jk=f.integrations.testConnection.useMutation,Uk=f.intercom.startSession.useMutation,Hk=f.intercom.handleAnswer.useMutation,Vk=f.intercom.stopSession.useMutation,Wk=f.intercom.startTalkSession.useMutation,qk=f.intercom.pushTalkPcm.useMutation,Kk=f.intercom.endTalkSession.useMutation,Zk=f.intercom.getStatus.useQuery,Yk=f.localNetwork.list.useQuery,Xk=f.localNetwork.getPreferred.useQuery,Jk=f.localNetwork.getConnectionEndpoints.useQuery,e2=f.localNetwork.getAllowedAddresses.useQuery,t2=f.localNetwork.setAllowedAddresses.useMutation,r2=f.localNetwork.resetAllowlistToBestMatch.useMutation,n2=f.meshNetwork.getStatus.useQuery,o2=f.meshNetwork.join.useMutation,s2=f.meshNetwork.startLogin.useMutation,a2=f.meshNetwork.leave.useMutation,i2=f.meshNetwork.logout.useMutation,l2=f.meshNetwork.listPeers.useQuery,c2=f.meshNetwork.testConnection.useMutation,u2=f.metricsProvider.collectSnapshot.useQuery,d2=f.metricsProvider.getCached.useQuery,p2=f.metricsProvider.getCurrent.useQuery,f2=f.metricsProvider.getDiskSpace.useQuery,m2=f.metricsProvider.getGpuInfo.useQuery,h2=f.metricsProvider.getCpuTemperature.useQuery,g2=f.metricsProvider.getProcessStats.useQuery,b2=f.metricsProvider.listAddonInstances.useQuery,v2=f.metricsProvider.getAddonStats.useQuery,y2=f.metricsProvider.listNodeProcesses.useQuery,x2=f.metricsProvider.killProcess.useMutation,w2=f.motion.isDetected.useQuery,k2=f.motion.getStatus.useQuery,N2=f.motionDetection.analyze.useMutation,S2=f.motionDetection.removeCamera.useMutation,C2=f.motionDetection.reset.useMutation,M2=f.motionDetection.getDeviceSettingsContribution.useQuery,E2=f.motionDetection.getDeviceLiveContribution.useQuery,A2=f.motionDetection.applyDeviceSettingsPatch.useMutation,P2=f.motionTrigger.setMotionTrigger.useMutation,R2=f.motionTrigger.getStatus.useQuery,_2=f.motionZones.getOptions.useQuery,I2=f.motionZones.setZone.useMutation,T2=f.motionZones.getStatus.useQuery,D2=f.mqttBroker.listBrokers.useQuery,L2=f.mqttBroker.getBrokerConfig.useQuery,O2=f.mqttBroker.addBroker.useMutation,$2=f.mqttBroker.removeBroker.useMutation,B2=f.mqttBroker.testConnection.useMutation,F2=f.mqttBroker.startEmbeddedBroker.useMutation,z2=f.mqttBroker.stopEmbeddedBroker.useMutation,G2=f.mqttBroker.getStatus.useQuery,Q2=f.nativeObjectDetection.setEnabled.useMutation,j2=f.nativeObjectDetection.getStatus.useQuery,U2=f.networkAccess.start.useMutation,H2=f.networkAccess.stop.useMutation,V2=f.networkAccess.getEndpoint.useQuery,W2=f.networkAccess.getStatus.useQuery,q2=f.networkAccess.listEndpoints.useQuery,K2=f.networkQuality.getDeviceStats.useQuery,Z2=f.networkQuality.getAllStats.useQuery,Y2=f.networkQuality.reportClientStats.useMutation,X2=f.nodes.topology.useQuery,J2=f.nodes.deployAddon.useMutation,eN=f.nodes.undeployAddon.useMutation,tN=f.nodes.restartAddon.useMutation,rN=f.nodes.restartProcess.useMutation,nN=f.nodes.restartNode.useMutation,oN=f.nodes.shutdownNode.useMutation,sN=f.nodes.renameNode.useMutation,aN=f.nodes.clusterAddonStatus.useQuery,iN=f.nodes.getCapUsageGraph.useQuery,lN=f.nodes.getNodeAddons.useQuery,cN=f.nodes.setProcessLogLevel.useMutation,uN=f.nodes.executeQuery.useMutation,dN=f.notificationOutput.send.useMutation,pN=f.notificationOutput.sendTest.useMutation,fN=f.osd.setOverlay.useMutation,mN=f.osd.getStatus.useQuery,hN=f.pipelineAnalytics.getActiveTracks.useQuery,gN=f.pipelineAnalytics.getTrack.useQuery,bN=f.pipelineAnalytics.listTracks.useQuery,vN=f.pipelineAnalytics.clearTracks.useMutation,yN=f.pipelineAnalytics.getMotionEvents.useQuery,xN=f.pipelineAnalytics.getObjectEvents.useQuery,wN=f.pipelineAnalytics.getAudioEvents.useQuery,kN=f.pipelineAnalytics.getEventMedia.useQuery,NN=f.pipelineAnalytics.getTrackMedia.useQuery,SN=f.pipelineAnalytics.getDeviceSettingsContribution.useQuery,CN=f.pipelineAnalytics.getDeviceLiveContribution.useQuery,MN=f.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,EN=f.pipelineExecutor.getAvailableEngines.useQuery,AN=f.pipelineExecutor.getSelectedEngine.useQuery,PN=f.pipelineExecutor.getDefaultSteps.useQuery,RN=f.pipelineExecutor.reprobeEngine.useMutation,_N=f.pipelineExecutor.getVideoPipelineSteps.useQuery,IN=f.pipelineExecutor.setVideoPipelineSteps.useMutation,TN=f.pipelineExecutor.getSchema.useQuery,DN=f.pipelineExecutor.getGlobalSteps.useQuery,LN=f.pipelineExecutor.getGlobalPipelineConfig.useQuery,ON=f.pipelineExecutor.getOrchestratorConfigSchema.useQuery,$N=f.pipelineExecutor.listTemplates.useQuery,BN=f.pipelineExecutor.saveTemplate.useMutation,FN=f.pipelineExecutor.updateTemplate.useMutation,zN=f.pipelineExecutor.deleteTemplate.useMutation,GN=f.pipelineExecutor.getCapabilities.useQuery,QN=f.pipelineExecutor.getAddonModels.useQuery,jN=f.pipelineExecutor.downloadModel.useMutation,UN=f.pipelineExecutor.deleteModel.useMutation,HN=f.pipelineExecutor.detect.useQuery,VN=f.pipelineExecutor.runPipeline.useMutation,WN=f.pipelineExecutor.runPipelineBatch.useMutation,qN=f.pipelineExecutor.cacheFrameInPool.useMutation,KN=f.pipelineExecutor.inferCached.useMutation,ZN=f.pipelineExecutor.uncacheFrame.useMutation,YN=f.pipelineExecutor.getEffectiveTuning.useQuery,XN=f.pipelineExecutor.listLoadedEngines.useQuery,JN=f.pipelineExecutor.spinEngine.useMutation,eS=f.pipelineExecutor.killEngine.useMutation,tS=f.pipelineExecutor.listReferenceImages.useQuery,rS=f.pipelineExecutor.getReferenceImage.useQuery,nS=f.pipelineExecutor.getReferenceAudioFiles.useQuery,oS=f.pipelineExecutor.getReferenceAudio.useQuery,sS=f.pipelineExecutor.getAudioCapabilities.useQuery,aS=f.pipelineExecutor.runAudioTest.useMutation,iS=f.pipelineExecutor.getDetectionConfigSchema.useQuery,lS=f.pipelineOrchestrator.assignPipeline.useMutation,cS=f.pipelineOrchestrator.unassignPipeline.useMutation,uS=f.pipelineOrchestrator.rebalance.useMutation,dS=f.pipelineOrchestrator.getPipelineAssignments.useQuery,pS=f.pipelineOrchestrator.getPipelineAssignment.useQuery,fS=f.pipelineOrchestrator.getAgentLoad.useQuery,mS=f.pipelineOrchestrator.getGlobalMetrics.useQuery,hS=f.pipelineOrchestrator.getCameraMetrics.useQuery,gS=f.pipelineOrchestrator.getCapabilityBindings.useQuery,bS=f.pipelineOrchestrator.setCapabilityBinding.useMutation,vS=f.pipelineOrchestrator.assignDecoder.useMutation,yS=f.pipelineOrchestrator.unassignDecoder.useMutation,xS=f.pipelineOrchestrator.getDecoderAssignments.useQuery,wS=f.pipelineOrchestrator.assignAudio.useMutation,kS=f.pipelineOrchestrator.unassignAudio.useMutation,NS=f.pipelineOrchestrator.getAudioAssignment.useQuery,SS=f.pipelineOrchestrator.getAudioNodeLoad.useQuery,CS=f.pipelineOrchestrator.getAudioAssignments.useQuery,MS=f.pipelineOrchestrator.getDecoderAssignment.useQuery,ES=f.pipelineOrchestrator.getAgentSettings.useQuery,AS=f.pipelineOrchestrator.listAgentSettings.useQuery,PS=f.pipelineOrchestrator.setAgentAddonDefaults.useMutation,RS=f.pipelineOrchestrator.removeAgentSettings.useMutation,_S=f.pipelineOrchestrator.getCameraSettings.useQuery,IS=f.pipelineOrchestrator.setCameraStepToggle.useMutation,TS=f.pipelineOrchestrator.getCameraStepOverrides.useQuery,DS=f.pipelineOrchestrator.setCameraStepOverride.useMutation,LS=f.pipelineOrchestrator.setCameraPipelineForAgent.useMutation,OS=f.pipelineOrchestrator.resolvePipeline.useQuery,$S=f.pipelineOrchestrator.listTemplates.useQuery,BS=f.pipelineOrchestrator.saveTemplate.useMutation,FS=f.pipelineOrchestrator.updateTemplate.useMutation,zS=f.pipelineOrchestrator.deleteTemplate.useMutation,GS=f.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,QS=f.pipelineOrchestrator.getDeviceLiveContribution.useQuery,jS=f.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,US=f.pipelineRunner.attachCamera.useMutation,HS=f.pipelineRunner.detachCamera.useMutation,VS=f.pipelineRunner.reportMotion.useMutation,WS=f.pipelineRunner.getLocalLoad.useQuery,qS=f.pipelineRunner.getLocalMetrics.useQuery,KS=f.pipelineRunner.getCameraMetrics.useQuery,ZS=f.pipelineRunner.getAllCameraMetrics.useQuery,YS=f.pipelineRunner.getLocalCameras.useQuery,XS=f.platformProbe.getCapabilities.useQuery,JS=f.platformProbe.getHardware.useQuery,eC=f.platformProbe.resolveInferenceConfig.useQuery,tC=f.platformProbe.resolveHwAccel.useQuery,rC=f.platformProbe.getHardwareEncoders.useQuery,nC=f.platformProbe.refreshHardwareEncoders.useMutation,oC=f.privacyMask.getOptions.useQuery,sC=f.privacyMask.setMask.useMutation,aC=f.privacyMask.getStatus.useQuery,iC=f.ptz.move.useMutation,lC=f.ptz.continuousMove.useMutation,cC=f.ptz.stop.useMutation,uC=f.ptz.getPresets.useQuery,dC=f.ptz.goToPreset.useMutation,pC=f.ptz.savePreset.useMutation,fC=f.ptz.deletePreset.useMutation,mC=f.ptz.getOptions.useQuery,hC=f.ptz.goHome.useMutation,gC=f.ptz.getPosition.useQuery,bC=f.ptz.setAutofocus.useMutation,vC=f.ptz.getStatus.useQuery,_g=f.ptzAutotrack.getStatus.useQuery,Ig=f.ptzAutotrack.setEnabled.useMutation,yC=f.ptzAutotrack.getSettings.useQuery,Tg=f.ptzAutotrack.setSettings.useMutation,xC=f.reboot.reboot.useMutation,wC=f.recording.getSegments.useQuery,kC=f.recording.getPlaybackUrl.useQuery,NC=f.recording.getThumbnailAt.useQuery,SC=f.recordingEngine.getStatus.useQuery,CC=f.recordingEngine.enable.useMutation,MC=f.recordingEngine.disable.useMutation,EC=f.recordingEngine.getConfig.useQuery,AC=f.recordingEngine.updateConfig.useMutation,PC=f.recordingEngine.getPlaylist.useQuery,RC=f.recordingEngine.getThumbnail.useQuery,_C=f.recordingEngine.getSegments.useQuery,IC=f.recordingEngine.getAvailability.useQuery,TC=f.recordingEngine.estimateStorage.useQuery,DC=f.recordingEngine.estimateGlobalStorage.useQuery,LC=f.recordingEngine.getStorageUsage.useQuery,OC=f.recordingEngine.setPolicy.useMutation,$C=f.recordingEngine.getPolicy.useQuery,BC=f.recordingEngine.getPolicyStatus.useQuery,FC=f.recordingEngine.getRetentionConfig.useQuery,zC=f.recordingEngine.updateRetentionConfig.useMutation,GC=f.recordingEngine.getMotionStats.useQuery,QC=f.settingsStore.get.useQuery,jC=f.settingsStore.set.useMutation,UC=f.settingsStore.query.useQuery,HC=f.settingsStore.insert.useMutation,VC=f.settingsStore.update.useMutation,WC=f.settingsStore.delete.useMutation,qC=f.settingsStore.count.useQuery,KC=f.settingsStore.isEmpty.useQuery,ZC=f.settingsStore.declareCollection.useMutation,YC=f.snapshot.getSnapshot.useQuery,XC=f.snapshot.invalidateCache.useMutation,JC=f.snapshot.getStatus.useQuery,e5=f.snapshot.getDeviceSettingsContribution.useQuery,t5=f.snapshot.getDeviceLiveContribution.useQuery,r5=f.snapshot.applyDeviceSettingsPatch.useMutation,n5=f.snapshotProvider.supportsDevice.useQuery,o5=f.snapshotProvider.getSnapshot.useQuery,s5=f.storage.resolve.useQuery,a5=f.storage.write.useMutation,i5=f.storage.read.useQuery,l5=f.storage.exists.useQuery,c5=f.storage.list.useQuery,u5=f.storage.delete.useMutation,d5=f.storage.getAvailableSpace.useQuery,p5=f.storage.beginUpload.useMutation,f5=f.storage.writeChunk.useMutation,m5=f.storage.finalizeUpload.useMutation,h5=f.storage.abortUpload.useMutation,g5=f.storage.beginDownload.useMutation,b5=f.storage.readChunk.useQuery,v5=f.storage.endDownload.useMutation,y5=f.storage.listLocations.useQuery,x5=f.storage.getDefaultLocation.useQuery,w5=f.storage.upsertLocation.useMutation,k5=f.storage.deleteLocation.useMutation,N5=f.storage.testLocation.useQuery,S5=f.storage.listProviders.useQuery,C5=f.storage.testConfig.useQuery,M5=f.streamBroker.publishCameraStream.useMutation,E5=f.streamBroker.retractCameraStream.useMutation,A5=f.streamBroker.assignProfile.useMutation,P5=f.streamBroker.unassignProfile.useMutation,R5=f.streamBroker.listAllCameraStreams.useQuery,_5=f.streamBroker.listAllProfileSlots.useQuery,I5=f.streamBroker.getBrokerStats.useQuery,T5=f.streamBroker.listClients.useQuery,D5=f.streamBroker.killClient.useMutation,L5=f.streamBroker.restartProfile.useMutation,O5=f.streamBroker.getStreamUrl.useQuery,$5=f.streamBroker.getStreamWithCodec.useMutation,B5=f.streamBroker.releaseStreamWithCodec.useMutation,F5=f.streamBroker.subscribeAudioChunks.useMutation,z5=f.streamBroker.pullAudioChunks.useQuery,G5=f.streamBroker.unsubscribeAudioChunks.useMutation,Q5=f.streamBroker.subscribeFrames.useMutation,j5=f.streamBroker.pullFrameHandles.useQuery,U5=f.streamBroker.unsubscribeFrames.useMutation,H5=f.streamBroker.setPreBufferDuration.useMutation,V5=f.streamBroker.getPreBufferInfo.useQuery,W5=f.streamBroker.getRtspPort.useQuery,q5=f.streamBroker.getAllRtspEntries.useQuery,K5=f.streamBroker.getRtspEntry.useQuery,Z5=f.streamBroker.regenerateRtspToken.useMutation,Y5=f.streamBroker.setRtspEnabled.useMutation,X5=f.streamBroker.isRtspEnabled.useQuery,J5=f.streamBroker.getDeviceSettingsContribution.useQuery,eM=f.streamBroker.getDeviceLiveContribution.useQuery,tM=f.streamBroker.applyDeviceSettingsPatch.useMutation,rM=f.streamCatalog.getCatalog.useQuery,nM=f.streamParams.getOptions.useQuery,oM=f.streamParams.setProfile.useMutation,sM=f.streamParams.getConfigSchema.useQuery,aM=f.streamParams.getStatus.useQuery,iM=f.switch.setState.useMutation,lM=f.switch.getStatus.useQuery,cM=f.system.info.useQuery,uM=f.system.health.useQuery,dM=f.system.featureFlags.useQuery,pM=f.system.networkAddresses.useQuery,fM=f.system.getRetentionConfig.useQuery,mM=f.system.setRetentionConfig.useMutation,hM=f.system.forceRetentionCleanup.useMutation,gM=f.toast.onToast.useSubscription,bM=f.turnProvider.getTurnServers.useQuery,vM=f.userManagement.listUsers.useQuery,yM=f.userManagement.createUser.useMutation,xM=f.userManagement.updateUser.useMutation,wM=f.userManagement.deleteUser.useMutation,kM=f.userManagement.resetPassword.useMutation,NM=f.userManagement.setUserScopes.useMutation,SM=f.userManagement.validateCredentials.useMutation,CM=f.userManagement.listApiKeys.useQuery,MM=f.userManagement.createApiKey.useMutation,EM=f.userManagement.revokeApiKey.useMutation,AM=f.userManagement.validateApiKey.useMutation,PM=f.userManagement.createScopedToken.useMutation,RM=f.userManagement.revokeScopedToken.useMutation,_M=f.userManagement.validateScopedToken.useQuery,IM=f.userManagement.listScopedTokens.useQuery,TM=f.userManagement.setupTotp.useMutation,DM=f.userManagement.confirmTotp.useMutation,LM=f.userManagement.disableTotp.useMutation,OM=f.userManagement.getTotpStatus.useQuery,$M=f.userManagement.verifyTotp.useMutation,BM=f.userManagement.oauthIssueCode.useMutation,FM=f.userManagement.oauthExchangeCode.useMutation,zM=f.userManagement.oauthRefresh.useMutation,GM=f.userManagement.oauthVerifyAccessToken.useQuery,QM=f.userManagement.listOauthSessions.useQuery,jM=f.userManagement.revokeOauthSession.useMutation,UM=f.webrtcSession.listStreams.useQuery,HM=f.webrtcSession.createSession.useMutation,VM=f.webrtcSession.handleOffer.useMutation,WM=f.webrtcSession.handleAnswer.useMutation,qM=f.webrtcSession.addIceCandidate.useMutation,KM=f.webrtcSession.getIceCandidates.useQuery,ZM=f.webrtcSession.closeSession.useMutation,YM=f.webrtcSession.hasAdaptiveBitrate.useQuery,XM=f.zoneAnalytics.getCurrentSnapshot.useQuery,JM=f.zoneAnalytics.getZoneHistory.useQuery,eE=f.zoneAnalytics.getCameraHistory.useQuery,tE=f.zoneAnalytics.getUnzonedHistory.useQuery,rE=f.zoneRules.listRules.useQuery,nE=f.zoneRules.setRules.useMutation,oE=f.zones.listZones.useQuery,sE=f.zones.addZone.useMutation,aE=f.zones.removeZone.useMutation,iE=f.zones.updateZone.useMutation,Zl=ht("camstack:widget-registry",null),tn=new Map,Rr=new Map,Hs=new Set;function zo(e,t){return`${e}::${t}`}function Dg(e){if(!e||typeof e!="object")return!1;const t=e.default;return t!==null&&typeof t=="object"}function Lg(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 Yl(e,t,r){const n=zo(e,t),s=tn.get(n);if(s)return s;const a=Rr.get(n);if(a)return a;Hs.has(e)||(Rp(),Cp([{name:e,entry:r,type:"module"}],{force:!1}),Hs.add(e));const i=Sp(`${e}/${t.startsWith("./")?t.slice(2):t}`).then(c=>{if(!Dg(c)){const u=Lg(c);throw new Error(`Remote ${e} (${r}) does not expose a default record on '${t}'. Got: ${JSON.stringify(u)}`)}const l=c.default;return tn.set(n,l),Rr.delete(n),l}).catch(c=>{throw Rr.delete(n),c});return Rr.set(n,i),i}function po(e,t){return tn.get(zo(e,t))}var Og=3e4,$g=2e3;function lE({children:e}){const t=xr(),r=J(Date.now()),{data:n}=Sg(void 0,{staleTime:0,refetchOnMount:"always",refetchInterval:l=>{const u=l.state.data;return u&&u.length>0||Date.now()-r.current>=Og?!1:$g}});cn("addon.widget-ready",()=>{t.invalidateQueries({queryKey:[["addonWidgets","listWidgets"]]})});const[s,a]=M(0),i=X(()=>n??[],[n]);Z(()=>{if(i.length===0)return;let l=!1;const u=new Set;for(const d of i){const p=zo(d.remote.remoteName,d.remote.exposedModule);if(u.has(p)||(u.add(p),tn.has(p)))continue;const h=d.bundleUrl;Yl(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=X(()=>{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=po(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(Zl.Provider,{value:c,children:e})}function cE(e){return Go().resolve(e)}function Bg(e){return Go().metadata(e)}function uE(){return Go().listAll()}function Fg(e,t){const r=Xl(),n=t??r?.entryUrlFor(e.remoteName),[s,a]=M(0),[i,c]=M(!1);return Z(()=>{if(!n||(c(!1),po(e.remoteName,e.exposedModule)))return;let l=!1;return Yl(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]),X(()=>{if(!n||i)return;const l=po(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 Go(){const e=Xl();if(!e)throw new Error("useWidgetRegistry(): no <WidgetRegistryProvider> in tree");return e}function Xl(){return zg(Zl)}function zg(e){return Pe(e)}function Gg({deviceId:e}){const t=Pt(et().trpcClient,e),[r,n]=M(null),[s,a]=M(!1);Z(()=>{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=I(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 Qg({deviceId:e}){const t=et(),r=Number.isFinite(e),n=Nl(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(Sl,{controls:n,mode:"panel"}),s&&o(Gg,{deviceId:e})]})}function jg(e){const t=xr(),r=_g({deviceId:e??0},{enabled:e!==null&&Number.isFinite(e),refetchInterval:5e3,retry:1}),n=Ig({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),s=Tg({onSuccess:()=>{t.invalidateQueries({queryKey:[["ptzAutotrack"]]})}}),a=I(async l=>{e!==null&&await n.mutateAsync({deviceId:e,enabled:l})},[e,n]),i=I(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 Ug({deviceId:e}){const{status:t,isLoading:r,isPending:n,error:s,setEnabled:a,setSettings:i}=jg(Number.isFinite(e)?e:null),[c,l]=M({targetType:"",stopDelaySeconds:30,disappearDelaySeconds:15}),[u,d]=M(!1);return Z(()=>{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(_o,{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(Kt,{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 Qo=ht("camstack:player-overlays-state",null),jo=ht("camstack:player-overlays-actions",null);function dE({children:e}){const[t,r]=M(()=>new Map),[n,s]=M(()=>new Map),a=I(p=>{r(h=>{const g=new Map(h);return g.set(p.id,p),g})},[]),i=I(p=>{r(h=>{if(!h.has(p))return h;const g=new Map(h);return g.delete(p),g})},[]),c=I(p=>{s(h=>{const g=new Map(h);return g.set(p.id,p),g})},[]),l=I(p=>{s(h=>{if(!h.has(p))return h;const g=new Map(h);return g.delete(p),g})},[]),u=X(()=>({layers:t,buttons:n}),[t,n]),d=X(()=>({setLayer:a,removeLayer:i,setButton:c,removeButton:l}),[a,i,c,l]);return o(Qo.Provider,{value:u,children:o(jo.Provider,{value:d,children:e})})}function pE(){const e=Pe(Qo);return X(()=>e?[...e.layers.values()].sort((t,r)=>t.order-r.order):[],[e])}function Hg(){const e=Pe(Qo);return X(()=>e?[...e.buttons.values()].sort((t,r)=>t.order-r.order):[],[e])}function Jl(e){const t=Pe(jo);Z(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function fE(e){const t=Pe(jo);Z(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}var ec={rect:"#ef4444",polygon:"#3b82f6",grid:"#6366f1",line:"#f59e0b"},tc="33",Uo="66",_r="#6366f1",Tt=3,Vs=2,Vg=12,In=16,Tn=9;function ir(e,t,r){return{x:e.x*t,y:e.y*r}}function fo(e,t,r){return{x:e.x/t,y:e.y/r}}function rc(e,t,r){return e.flatMap(n=>[n.x*t,n.y*r])}function $t(e){return!Number.isFinite(e)||e<0?0:e>1?1:e}function Wg(e){return e.color??ec[e.shape.kind]}function qg(e,t){const r=e[t],n=e[(t+1)%e.length];if(!r||!n)return[...e];const s={x:(r.x+n.x)/2,y:(r.y+n.y)/2};return[...e.slice(0,t+1),s,...e.slice(t+1)]}function Kg(e,t){return e.length!==t.length?!1:e.every((r,n)=>{const s=t[n];return Math.abs(r.x-s.x)<1e-6&&Math.abs(r.y-s.y)<1e-6})}function Zg(e){return e.kind==="polygon"||e.kind==="line"}function Yg({items:e,selectedId:t,onSelect:r,onShapeChange:n,onDrawComplete:s,drawingKind:a,supportedShapes:i,transparent:c=!1,backdrop:l,polygonVertices:u,grid:d}){const p=J(null),[h,g]=M({w:800,h:450}),[b,v]=M([]),[y,x]=M(null),[w,k]=M(null),[S,N]=M(null),E=a!==null&&i.includes(a);Z(()=>{if(!S)return;const R=e.find(T=>T.id===S.itemId);if(!R||!Zg(R.shape)){N(null);return}Kg(R.shape.points,S.points)&&N(null)},[e,S]),Z(()=>{const R=p.current;if(!R)return;const T=new ResizeObserver(L=>{const z=L[0];if(!z)return;const{width:B,height:ee}=z.contentRect;g(c?{w:B,h:ee}:{w:B,h:B*9/16})});return T.observe(R),()=>T.disconnect()},[c]),Z(()=>{!E&&y!==null&&x(null)},[E,y]);const D=I(R=>{s(R),v([])},[s]),C=I(R=>{if(!E||a===null){r(null);return}const T=R.target.getStage();if(!T)return;const L=T.getPointerPosition();if(!L)return;const z=fo(L,h.w,h.h);if(a==="rect"){const B=$t(z.x),ee=$t(z.y);D({kind:"rect",x:B,y:ee,width:Math.min(.2,1-B),height:Math.min(.2,1-ee)});return}if(a==="grid"){const B=d?.width??In,ee=d?.height??Tn;D({kind:"grid",gridWidth:B,gridHeight:ee,cells:Array.from({length:B*ee},()=>!1)});return}if(a==="line"){if(b.length===0){v([z]);return}D({kind:"line",points:[...b,z]});return}if(a==="polygon"){if(b.length===0){v([z]);return}if(b.length>=Tt){const B=ir(b[0],h.w,h.h);if(Math.hypot(L.x-B.x,L.y-B.y)<Vg){D({kind:"polygon",points:b});return}}v(B=>[...B,z])}},[E,a,b,h,d,D,r]),_=I(R=>{!E||a!=="polygon"||b.length<Tt||(R.cancelBubble=!0,D({kind:"polygon",points:b}))},[E,a,b,D]),O=J(null),ae=J(null);Z(()=>()=>{O.current!==null&&cancelAnimationFrame(O.current)},[]);const de=I(R=>{if(!E)return;const T=R.target.getStage();T&&(ae.current=T.getPointerPosition()??null,O.current===null&&(O.current=requestAnimationFrame(()=>{O.current=null,x(ae.current)})))},[E]),le=J(!1),W=J(!0),V=J(new Set),Y=I((R,T,L,z)=>{const B=T.gridWidth*T.gridHeight;if(L<0||L>=B||T.cells[L]===z)return;const ee=[...T.cells];for(;ee.length<B;)ee.push(!1);ee.length=B,ee[L]=z,n(R,{...T,cells:ee})},[n]),K=[];if(!c){for(let R=1;R<In;R++){const T=h.w/In*R;K.push(o(xt,{points:[T,0,T,h.h],stroke:"#ffffff",strokeWidth:.5,opacity:.08},`gv-${R}`))}for(let R=1;R<Tn;R++){const T=h.h/Tn*R;K.push(o(xt,{points:[0,T,h.w,T],stroke:"#ffffff",strokeWidth:.5,opacity:.08},`gh-${R}`))}}return m("div",{ref:p,className:c?"absolute inset-0":"relative w-full bg-zinc-900 rounded-lg overflow-hidden",style:{cursor:E?"crosshair":"default"},children:[l&&!c?o("div",{className:"absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover",style:{width:h.w,height:h.h},children:l}):null,m(Oc,{width:h.w,height:h.h,onClick:C,onDblClick:_,onMouseMove:de,children:[m(mn,{listening:!1,children:[o(xt,{points:[0,0,h.w,0,h.w,h.h,0,h.h,0,0],stroke:"transparent",strokeWidth:0}),K]}),o(mn,{children:e.map(R=>{const T=R.id===t,L=R.enabled===!1,z=Wg(R),B=T&&!E&&!L;if(R.shape.kind==="rect")return o(Jg,{item:R,shape:R.shape,color:z,selected:T,dimmed:L,editable:B,isDrawing:E,size:h,onSelect:r,onShapeChange:n},R.id);if(R.shape.kind==="grid")return o(eb,{item:R,shape:R.shape,color:z,dimmed:L,editable:B,size:h,onSelect:r,paintingRef:le,paintValueRef:W,paintedRef:V,paintCell:Y},R.id);const ee=R.shape.kind==="line",P=ee?Vs:Math.max(Tt,u?.min??Tt),F=ee?Vs:u?.max,U=S&&S.itemId===R.id?S.points:R.shape.points;return o(tb,{item:R,shape:R.shape,color:z,selected:T,dimmed:L,editable:B,isLine:ee,isDrawing:E,size:h,effectivePoints:U,minVertices:P,maxVertices:F,isDragging:w===R.id,onSelect:r,onShapeChange:n,setDragOverride:N,setDraggingItemId:k},R.id)})}),o(mn,{listening:!1,children:E&&b.length>0&&m(jt,{children:[a==="polygon"&&b.length>=2&&o(xt,{points:rc(b,h.w,h.h),stroke:_r,strokeWidth:1.5,dash:[6,3],opacity:.8}),a==="line"&&b.length===1&&y&&o(xt,{points:[b[0].x*h.w,b[0].y*h.h,y.x,y.y],stroke:ec.line,strokeWidth:1.5,dash:[6,3],opacity:.7}),a==="polygon"&&y&&b.length>=1&&o(xt,{points:[b[b.length-1].x*h.w,b[b.length-1].y*h.h,y.x,y.y],stroke:_r,strokeWidth:1,dash:[4,4],opacity:.5}),b.map((R,T)=>{const L=ir(R,h.w,h.h),z=T===0&&a==="polygon"&&b.length>=Tt;return o(qr,{x:L.x,y:L.y,radius:z?7:4,fill:z?_r:"#ffffff",stroke:_r,strokeWidth:1.5,opacity:.9},T)})]})})]}),E?o("div",{className:"px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700",children:a==="line"?"Click to set the start point, click again to complete the line":a==="rect"?"Click to drop a rectangle, then drag the corner to resize":a==="grid"?"Click to add the grid, then paint cells":b.length<Tt?"Click to add points (min 3). Double-click or click the first point to close.":"Continue adding points. Double-click or click the first point to close."}):null]})}var Ir=.02;function Xg(e,t){return Math.abs(e.x-t.x)<1e-6&&Math.abs(e.y-t.y)<1e-6&&Math.abs(e.width-t.width)<1e-6&&Math.abs(e.height-t.height)<1e-6}function Jg({item:e,shape:t,color:r,selected:n,dimmed:s,editable:a,isDrawing:i,size:c,onSelect:l,onShapeChange:u}){const[d,p]=M(null),h={x:t.x,y:t.y,width:t.width,height:t.height};Z(()=>{d&&Xg(h,d)&&p(null)},[t.x,t.y,t.width,t.height,d]);const g=d??h,b=g.x*c.w,v=g.y*c.h,y=g.width*c.w,x=g.height*c.h,w=s?.35:n?1:.85,k=C=>{p(C),u(e.id,{kind:"rect",x:C.x,y:C.y,width:C.width,height:C.height})},S=C=>({x:Math.max(-b,Math.min(c.w-(b+y),C.x)),y:Math.max(-v,Math.min(c.h-(v+x),C.y))}),N=C=>{const _=C.target,O=_.x()/c.w,ae=_.y()/c.h;if(_.position({x:0,y:0}),O===0&&ae===0)return;const de=Math.min(Math.max(0,g.x+O),Math.max(0,1-g.width)),le=Math.min(Math.max(0,g.y+ae),Math.max(0,1-g.height));k({...g,x:de,y:le})},E=C=>{const _=C.target,O=$t(_.x()/c.w-g.x),ae=$t(_.y()/c.h-g.y);p({...g,width:Math.max(Ir,Math.min(O,1-g.x)),height:Math.max(Ir,Math.min(ae,1-g.y))})},D=C=>{const _=C.target,O=$t(_.x()/c.w-g.x),ae=$t(_.y()/c.h-g.y);k({...g,width:Math.max(Ir,Math.min(O,1-g.x)),height:Math.max(Ir,Math.min(ae,1-g.y))})};return o(jt,{onClick:C=>{C.cancelBubble=!0,i||l(e.id)},children:m(jt,{draggable:a,dragBoundFunc:a?S:void 0,onDragEnd:a?N:void 0,onMouseEnter:C=>{if(!a)return;const _=C.target.getStage();_&&(_.container().style.cursor="move")},onMouseLeave:C=>{if(!a)return;const _=C.target.getStage();_&&(_.container().style.cursor=i?"crosshair":"default")},children:[o(ya,{x:b,y:v,width:y,height:x,fill:r+(n?Uo:tc),stroke:r,strokeWidth:n?2.5:1.5,opacity:w}),e.label?o(xa,{x:b,y:v-16,text:e.label,fontSize:12,fill:r,stroke:"#000000",strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:"bold",listening:!1}):null,a?o(qr,{x:b+y,y:v+x,radius:6,fill:r,stroke:"#ffffff",strokeWidth:1.5,draggable:!0,dragBoundFunc:C=>({x:Math.min(c.w,Math.max(b,C.x)),y:Math.min(c.h,Math.max(v,C.y))}),onDragStart:C=>{C.cancelBubble=!0},onDragMove:E,onDragEnd:D,onMouseEnter:C=>{const _=C.target.getStage();_&&(_.container().style.cursor="nwse-resize")},onMouseLeave:C=>{const _=C.target.getStage();_&&(_.container().style.cursor="default")}}):null]})})}function eb({item:e,shape:t,color:r,dimmed:n,editable:s,size:a,onSelect:i,paintingRef:c,paintValueRef:l,paintedRef:u,paintCell:d}){const{gridWidth:p,gridHeight:h,cells:g}=t,b=a.w/p,v=a.h/h,y=p*h,x=n?.3:1,w=N=>{if(!s){i(e.id);return}const E=g[N]!==!0;c.current=!0,l.current=E,u.current=new Set([N]),d(e.id,t,N,E)},k=N=>{!c.current||!s||u.current.has(N)||(u.current.add(N),d(e.id,t,N,l.current))},S=()=>{c.current&&(c.current=!1,u.current=new Set)};return o(jt,{opacity:x,onMouseUp:S,onMouseLeave:S,children:Array.from({length:y},(N,E)=>{const D=E%p,C=Math.floor(E/p),_=g[E]===!0;return o(ya,{x:D*b,y:C*v,width:b,height:v,fill:_?r+Uo:"#ffffff10",stroke:_?r:"#ffffff40",strokeWidth:.5,onMouseDown:O=>{O.cancelBubble=!0,w(E)},onMouseEnter:()=>k(E)},E)})})}function tb({item:e,shape:t,color:r,selected:n,dimmed:s,editable:a,isLine:i,isDrawing:c,size:l,effectivePoints:u,minVertices:d,maxVertices:p,isDragging:h,onSelect:g,onShapeChange:b,setDragOverride:v,setDraggingItemId:y}){const x=rc(u,l.w,l.h),w=s?.35:n?1:i?.8:.85,k=W=>i?{kind:"line",points:[...W]}:{kind:"polygon",points:[...W]},S=u.map(W=>W.x*l.w),N=u.map(W=>W.y*l.h),E=S.length>0?Math.min(...S):0,D=S.length>0?Math.max(...S):0,C=N.length>0?Math.min(...N):0,_=N.length>0?Math.max(...N):0,O=W=>({x:Math.max(-E,Math.min(l.w-D,W.x)),y:Math.max(-C,Math.min(l.h-_,W.y))}),ae=W=>{const V=W.target,Y=V.x()/l.w,K=V.y()/l.h;if(V.position({x:0,y:0}),y(null),Y===0&&K===0)return;const R=t.points.map(T=>({x:T.x+Y,y:T.y+K}));v({itemId:e.id,points:R}),b(e.id,k(R))},de=!i&&u.length>d,le=!i&&(p===void 0||u.length<p);return m(jt,{onClick:W=>{W.cancelBubble=!0,c||g(e.id)},children:[m(jt,{draggable:a,dragBoundFunc:a?O:void 0,onDragStart:a?()=>y(e.id):void 0,onDragEnd:a?ae:void 0,onMouseEnter:W=>{if(!a)return;const V=W.target.getStage();V&&(V.container().style.cursor="move")},onMouseLeave:W=>{if(!a)return;const V=W.target.getStage();V&&(V.container().style.cursor=c?"crosshair":"default")},children:[i?o($c,{points:x,stroke:r,strokeWidth:n?3:2,fill:r,pointerLength:10,pointerWidth:8,opacity:w}):o(xt,{points:x,closed:!0,fill:r+(n?Uo:tc),stroke:r,strokeWidth:n?2.5:1.5,opacity:w}),e.label&&u.length>0?(()=>{const W=ir({x:u.reduce((Y,K)=>Y+K.x,0)/u.length,y:u.reduce((Y,K)=>Y+K.y,0)/u.length},l.w,l.h),V=Math.max(40,e.label.length*11*.62);return o(xa,{x:W.x-V/2,y:W.y-7,width:V,align:"center",text:e.label,fontSize:12,fill:r,stroke:"#000000",strokeWidth:3,fillAfterStrokeEnabled:!0,fontStyle:"bold",listening:!1})})():null]}),a&&!h&&u.map((W,V)=>{const Y=ir(W,l.w,l.h);return o(qr,{x:Y.x,y:Y.y,radius:5,fill:r,stroke:"#ffffff",strokeWidth:1.5,draggable:!0,onDragMove:K=>{const R=fo({x:K.target.x(),y:K.target.y()},l.w,l.h);v(T=>{const L=T&&T.itemId===e.id?T.points:t.points;return{itemId:e.id,points:L.map((z,B)=>B===V?R:z)}})},onDragEnd:K=>{const R=fo({x:K.target.x(),y:K.target.y()},l.w,l.h),T=t.points.map((L,z)=>z===V?R:L);v({itemId:e.id,points:T}),b(e.id,k(T))},onContextMenu:K=>{K.evt.preventDefault(),K.cancelBubble=!0,de&&b(e.id,k(t.points.filter((R,T)=>T!==V)))}},`pt-${V}`)}),a&&!h&&le&&u.length>=2&&u.map((W,V)=>{const Y=u[(V+1)%u.length],K=ir({x:(W.x+Y.x)/2,y:(W.y+Y.y)/2},l.w,l.h);return o(qr,{x:K.x,y:K.y,radius:4,fill:"#ffffff",stroke:r,strokeWidth:1.5,opacity:.6,onMouseEnter:R=>{const T=R.target;T.to({radius:6,opacity:1,duration:.1});const L=T.getStage();L&&(L.container().style.cursor="copy")},onMouseLeave:R=>{const T=R.target;T.to({radius:4,opacity:.6,duration:.1});const L=T.getStage();L&&(L.container().style.cursor=c?"crosshair":"default")},onClick:R=>{R.cancelBubble=!0,b(e.id,k(qg(t.points,V)))}},`mid-${V}`)})]})}var nc=Ec(Yg),rb=110,nb="motion-zones",Dn=0,ob=[1,2,3],Ln=1,rr="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",On="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";function Ws(e,t,r){const n=t*r,s=new Array(n);for(let a=0;a<n;a+=1)s[a]=e[a]===!0;return s}function sb(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 dt(e,t){return Math.ceil(e/t)}function rn(e,t,r){return Math.min(r-1,Math.floor((e+.5)/t*r))}function Tr(e,t,r,n){const s=dt(t,n),a=dt(r,n),i=new Array(s*a).fill(!1);for(let c=0;c<r;c+=1){const l=rn(c,r,a);for(let u=0;u<t;u+=1)e[c*t+u]===!0&&(i[l*s+rn(u,t,s)]=!0)}return i}function $n(e,t,r,n){const s=dt(t,n),a=dt(r,n),i=new Array(t*r).fill(!1);for(let c=0;c<r;c+=1){const l=rn(c,r,a);for(let u=0;u<t;u+=1)i[c*t+u]=e[l*s+rn(u,t,s)]===!0}return i}function ab({deviceId:e}){const t=Pt(et().trpcClient,e),[r,n]=M(null),[s,a]=M(!1),[i,c]=M(null),[l,u]=M(null),[d,p]=M(Ln),[h,g]=M(!1),[b,v]=M(!1),y=J(!1);Z(()=>{if(!t)return;let R=!1;return y.current=!1,n(null),a(!1),c(null),u(null),p(Ln),v(!1),(async()=>{try{const T=await t.motionZones?.getOptions({});if(R)return;if(!T)throw new Error("device proxy not ready");if(n(T),y.current)return;const L=await t.motionZones?.getStatus({});if(R)return;if(!L)throw new Error("device proxy not ready");y.current=!0;const z=L.regions.find(ee=>ee.shape.kind==="grid"),B=Ws(z?z.shape.cells:[],T.grid.width,T.grid.height);u(B),c(Tr(B,T.grid.width,T.grid.height,Ln))}catch(T){if(R)return;Zr(T)?a(!0):console.error("Motion Zones load failed",T)}})(),()=>{R=!0}},[t]);const x=r?r.grid.width:0,w=r?r.grid.height:0,k=dt(x,d),S=dt(w,d),N=X(()=>i&&r?$n(i,x,w,d):null,[i,r,x,w,d]),E=X(()=>N!==null&&l!==null&&!sb(N,l),[N,l]),D=X(()=>N?N.reduce((R,T)=>T?R+1:R,0):0,[N]),C=x*w,_=k*S,O=I(R=>{_>0&&c(new Array(_).fill(R))},[_]),ae=I(()=>{c(R=>R&&R.map(T=>!T))},[]),de=I(()=>{l&&r&&c(Tr(l,x,w,d))},[l,r,x,w,d]),le=I(R=>{R===d||!r||c(T=>{if(!T)return p(R),T;const L=Tr($n(T,x,w,d),x,w,R);return p(R),L})},[d,r,x,w]),W=X(()=>r&&i?[{id:Dn,shape:{kind:"grid",gridWidth:k,gridHeight:S,cells:[...i]}}]:[],[r,i,k,S]),V=I((R,T)=>{T.kind==="grid"&&c(T.cells)},[]),Y=I(async()=>{if(!(!t||!i||!r)){g(!0);try{const R=$n(i,r.grid.width,r.grid.height,d),T={kind:"grid",gridWidth:r.grid.width,gridHeight:r.grid.height,cells:R};await t.motionZones?.setZone({patch:{regions:[{id:Dn,enabled:!0,shape:T}]}});const L=await t.motionZones?.getStatus({});if(L){const z=L.regions.find(ee=>ee.shape.kind==="grid"),B=Ws(z?z.shape.cells:[],r.grid.width,r.grid.height);u(B),c(Tr(B,r.grid.width,r.grid.height,d))}}catch(R){console.error("Motion Zones save failed",R)}finally{g(!1)}}},[t,i,r,d]);Jl(X(()=>b&&!s&&r&&i?{id:nb,order:rb,node:o(nc,{transparent:!0,items:W,supportedShapes:["grid"],grid:{width:k,height:S},selectedId:Dn,onSelect:()=>{},onShapeChange:V,onDrawComplete:()=>{},drawingKind:null})}:null,[b,s,r,i,W,V,k,S]));const K=!s&&r!==null&&i!==null;return t?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:`${ot} leading-relaxed`,children:"This camera doesn't expose an on-board motion zones grid."}):K?m(ve,{children:[m("p",{className:`${ot} leading-relaxed`,children:["Toggle ",o("strong",{className:"text-foreground",children:"Edit grid"})," to paint the region directly on the live frame, then ",o("strong",{className:"text-foreground",children:"Save"})," to push the mask to the camera. Pick a bigger ",o("strong",{className:"text-foreground",children:"Cell size"})," ","for quicker, broad-stroke painting — it's resampled to the camera's native"," ",r.grid.width,"×",r.grid.height," grid on save (×1 is the finest)."]}),m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("button",{type:"button",onClick:()=>v(R=>!R),disabled:h,"aria-pressed":b,className:b?On:rr,children:b?"Done editing":"Edit grid"}),o("button",{type:"button",onClick:()=>O(!0),disabled:h,className:rr,children:"All on"}),o("button",{type:"button",onClick:()=>O(!1),disabled:h,className:rr,children:"All off"}),o("button",{type:"button",onClick:ae,disabled:h,className:rr,children:"Invert"}),m("div",{className:"flex items-center gap-1 ml-1",role:"group","aria-label":"Cell size",children:[o("span",{className:`${ot} mr-0.5`,children:"Cell size"}),ob.map(R=>m("button",{type:"button",onClick:()=>le(R),disabled:h,"aria-pressed":d===R,title:R===1?`Camera grid ${x}×${w} (finest)`:`${dt(x,R)}×${dt(w,R)} painting grid · cells ×${R} bigger`,className:d===R?On:rr,children:["×",R]},R))]}),m("span",{className:`${ot} ml-1 tabular-nums`,children:[D," / ",C," cells · ",r.grid.width,"×",r.grid.height,d!==1?` · paint ${k}×${S}`:""]}),o("span",{className:"flex-1"}),o("button",{type:"button",onClick:de,disabled:h||!E,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 Y(),disabled:h||!E,className:On,children:h?"Saving…":"Save"})]})]}):o("p",{className:`${ot} leading-relaxed`,children:"Loading the camera's grid…"})]}):null}var ib=120,lb="privacy-mask",Dr="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",nr="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";function qs(e){return e.kind==="rect"||e.kind==="polygon"?e:null}function cb(e){const t=new Set(e.map(n=>n.id));let r=0;for(;t.has(r);)r+=1;return r}function ub(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(JSON.stringify(e[r])!==JSON.stringify(t[r]))return!1;return!0}function db({deviceId:e}){const t=Pt(et().trpcClient,e),[r,n]=M(null),[s,a]=M(!1),[i,c]=M(null),[l,u]=M(null),[d,p]=M(!1),[h,g]=M(!1),[b,v]=M(null),[y,x]=M(null),w=J(!1);Z(()=>{if(!t)return;let P=!1;return w.current=!1,n(null),a(!1),c(null),u(null),g(!1),v(null),x(null),(async()=>{try{const F=await t.privacyMask?.getOptions({});if(P)return;if(!F)throw new Error("device proxy not ready");if(n(F),w.current)return;const U=await t.privacyMask?.getStatus({});if(P)return;if(!U)throw new Error("device proxy not ready");w.current=!0;const q={enabled:U.enabled,regions:U.regions};u(q),c(q)}catch(F){if(P)return;Zr(F)?a(!0):console.error("Privacy Mask load failed",F)}})(),()=>{P=!0}},[t]);const k=X(()=>i!==null&&l!==null&&(i.enabled!==l.enabled||!ub(i.regions,l.regions)),[i,l]),S=i?i.regions.length:0,N=r?r.maxRegions:0,E=J(0);Z(()=>{E.current=N},[N]);const D=N>0&&S>=N,C=I(()=>{c(P=>P&&{...P,enabled:!P.enabled})},[]),_=I(P=>{v(typeof P=="number"?P:null)},[]),O=X(()=>i?i.regions.map(P=>({id:P.id,shape:P.shape,enabled:P.enabled,label:`Zone ${String(P.id)}`})):[],[i]),ae=I((P,F)=>{const U=qs(F);U&&c(q=>q&&{...q,regions:q.regions.map(se=>se.id===P?{...se,shape:U}:se)})},[]),de=I(P=>{const F=qs(P);F&&(x(null),c(U=>{if(!U)return U;const q=E.current;if(q>0&&U.regions.length>=q)return U;const se=cb(U.regions),te={id:se,enabled:!0,shape:F};return v(se),{...U,regions:[...U.regions,te]}}))},[]),le=I(P=>{g(!0),v(null),x(P)},[]),W=I(P=>{g(!0),x(null),v(P)},[]),V=I(P=>{v(F=>F===P?null:F),c(F=>F&&{...F,regions:F.regions.filter(U=>U.id!==P)})},[]),Y=I(()=>{x(null),v(null),l&&c({enabled:l.enabled,regions:l.regions})},[l]),K=I(async()=>{if(!(!t||!i)){p(!0);try{await t.privacyMask?.setMask({patch:{enabled:i.enabled,regions:[...i.regions]}});const P=await t.privacyMask?.getStatus({});if(P){const F={enabled:P.enabled,regions:P.regions};u(F),c(F)}}catch(P){console.error("Privacy Mask save failed",P)}finally{p(!1)}}},[t,i]),R=I(()=>{g(P=>(P&&(x(null),v(null)),!P))},[]),T=r?.supportedShapes??[];Jl(X(()=>h&&!s&&r&&i?{id:lb,order:ib,node:o(nc,{transparent:!0,items:O,supportedShapes:T,polygonVertices:r.polygonVertices,selectedId:b,onSelect:_,onShapeChange:ae,onDrawComplete:de,drawingKind:y})}:null,[h,s,r,i,O,T,b,_,ae,de,y]));const L=r?.supportedShapes.includes("rect")??!1,z=r?.supportedShapes.includes("polygon")??!1,B=r!==null&&(r.maxRegions<=0||r.supportedShapes.length===0),ee=!s&&!B&&r!==null&&i!==null;return t?m("div",{className:"flex flex-col gap-3",children:[o("h3",{className:"text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider",children:"Privacy Mask"}),s||B?o("p",{className:`${ot} leading-relaxed`,children:"This camera doesn't support an on-board privacy mask."}):ee?m(ve,{children:[m("p",{className:`${ot} leading-relaxed`,children:["Toggle ",o("strong",{className:"text-foreground",children:"Edit mask"})," to draw blanked-out zones on the live frame, then ",o("strong",{className:"text-foreground",children:"Save"})," to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it."]}),m("div",{className:"flex items-center gap-2 flex-wrap",children:[o("button",{type:"button",onClick:R,disabled:d,"aria-pressed":h,className:h?nr:Dr,children:h?"Done editing":"Edit mask"}),o("button",{type:"button",onClick:C,disabled:d,"aria-pressed":i.enabled,className:i.enabled?nr:Dr,children:i.enabled?"Mask on":"Mask off"}),L&&o("button",{type:"button",onClick:()=>le("rect"),disabled:d||D,"aria-pressed":y==="rect",className:y==="rect"?nr:Dr,title:D?"Maximum zones reached":"Add a rectangle zone",children:"+ Rect"}),z&&o("button",{type:"button",onClick:()=>le("polygon"),disabled:d||D,"aria-pressed":y==="polygon",className:y==="polygon"?nr:Dr,title:D?"Maximum zones reached":"Add a polygon zone",children:"+ Polygon"}),m("span",{className:`${ot} ml-1 tabular-nums`,children:[S," / ",N," zones"]}),o("span",{className:"flex-1"}),o("button",{type:"button",onClick:Y,disabled:d||!k,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 K(),disabled:d||!k,className:nr,children:d?"Saving…":"Save"})]}),S>0?o("div",{className:"flex flex-col gap-1",children:i.regions.map(P=>{const F=b===P.id,U=P.shape.kind==="polygon"?cf:eo;return m("div",{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${F?"border-primary/50 bg-primary/10":"border-border bg-surface"}`,children:[m("button",{type:"button",onClick:()=>W(P.id),disabled:d,className:"flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors",children:[o(U,{className:"h-3.5 w-3.5 shrink-0"}),m("span",{children:["Zone ",P.id]}),o("span",{className:"text-foreground-faint capitalize",children:P.shape.kind})]}),o("button",{type:"button",onClick:()=>V(P.id),disabled:d,"aria-label":`Delete zone ${String(P.id)}`,title:"Delete zone",className:"inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors",children:o(Xe,{className:"h-3.5 w-3.5"})})]},P.id)})}):null]}):o("p",{className:`${ot} leading-relaxed`,children:"Loading the camera's privacy mask…"})]}):null}var pb={"host/motion-zones-grid":ab,"host/privacy-mask-grid":db,"host/ptz-panel":Qg,"host/ptz-autotrack":Ug};function fb(e){const{widgetId:t,deviceId:r}=e,n=pb[t];return n!==void 0?r===void 0?o(lr,{widgetId:t,reason:"missing-device-context"}):o(n,{deviceId:r}):o(mb,{...e})}function mb(e){const{widgetId:t}=e,r=Bg(t);return r===void 0?o(lr,{widgetId:t,reason:"unknown"}):o(hb,{...e,metadata:r})}function hb(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=Fg(d.remote,d.bundleUrl),h=X(()=>i??t,[i,t]);return p===null?o(gb,{}):p===void 0?o(lr,{widgetId:t,reason:"missing-export"}):d.requires.deviceContext&&s===void 0?o(lr,{widgetId:t,reason:"missing-device-context"}):d.requires.integrationContext&&a===void 0?o(lr,{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 gb(){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 lr({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 Rt="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",pn="block text-[11px] font-medium text-foreground mb-1 break-words",bb="text-[10px] text-foreground-subtle mt-0.5 break-words";function Ee({label:e,description:t,required:r,span:n,children:s,translationFn:a}){const i=n===2?"col-span-1 @[480px]:col-span-2":n===3?"col-span-1 @[480px]:col-span-2 @[880px]:col-span-3":n===4?"col-span-1 @[480px]:col-span-2 @[1140px]: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:pn,children:[c,r&&o("span",{className:"text-danger ml-0.5",children:"*"})]}),s,l&&o("p",{className:bb,children:l})]})}function vb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){return o(Ee,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("input",{type:e.inputType??"text",className:Rt,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 yb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const[a,i]=M(t==null?"":String(t)),c=J(!1);Z(()=>{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(Ee,{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:Rt,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 xb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=!!t,i=n||e.disabled;return e.style==="checkbox"?o(Ee,{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(Ee,{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:pn+" 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 wb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=e.options.some(i=>i.value==="");return o(Ee,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:m("select",{className:Rt,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 kb({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(Ee,{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 Nb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const[a,i]=M(!1),c=e.showToggle!==!1;return o(Ee,{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:Rt+(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(Io,{className:"h-3.5 w-3.5"}):o(Zt,{className:"h-3.5 w-3.5"})})]})})}function Sb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){return o(Ee,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:s,children:o("textarea",{className:Rt+" 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 Cb({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(Ee,{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=k=>{const S=c+k*(e.step??1),N=Math.min(e.max,Math.max(e.min,S));N!==c&&r(N)},w="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(Ee,{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:k=>r(Number(k.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:w,disabled:d||c<=e.min,onClick:()=>x(-1),title:`Decrease by ${e.step??1}`,"aria-label":"Decrement",children:o(Fi,{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:k=>{if(k.target.value===""){r(i?null:e.min);return}const S=Number(k.target.value)*p,N=e.step??1,E=S-e.min,D=e.min+Math.round(E/N)*N;r(Math.min(e.max,Math.max(e.min,D)))}}),y&&o("button",{type:"button",className:w,disabled:d||c>=e.max,onClick:()=>x(1),title:`Increase by ${e.step??1}`,"aria-label":"Increment",children:o(Yt,{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 Mb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=Array.isArray(t)?t:[],[i,c]=M(""),l=J(null),u=I(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(Ee,{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(Re,{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 Eb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const{nodes:a}=Bo(),i=typeof t=="string"?t:"",c=e.showOffline?a:a.filter(l=>l.isOnline);return o(Ee,{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 Ab({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const{nodes:a}=Bo(),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(Ee,{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 Pb({field:e,value:t,onChange:r,disabled:n,translationFn:s}){const a=t==null?"#000000":String(t);return m(Ee,{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:Rt+" 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 Rb({field:e,value:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i,externalProbe:c}){const[l,u]=M("idle"),[d,p]=M(null),h=c?.status??l,g=c?.result??d,b=!!a||!!i,v=I(async()=>{if(b){u("probing"),p(null);try{const w=a?await a(e.key,t):await i("test-probe",e.key,t),k=w&&typeof w=="object"?w:{status:"error",error:"Probe handler returned no result"};p(k),u(k.status==="ok"?"ok":"error")}catch(w){p({status:"error",error:w instanceof Error?w.message:String(w)}),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(Yp,{className:"h-3 w-3"}):h==="error"?o(Kt,{className:"h-3 w-3"}):o(Hi,{className:"h-3 w-3"});return m(Ee,{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:Rt+" flex-1 min-w-0",value:t==null?"":String(t),placeholder:e.placeholder,disabled:n||e.disabled,onChange:w=>{r(w.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((w,k)=>o("span",{className:"text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono",children:w},k))}),h==="error"&&g?.error&&o("p",{className:"text-xs text-danger mt-1 truncate",title:g.error,children:g.error})]})}function _b({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a}){const[i,c]=M(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"} min-w-0`,children:m("div",{className:"@container rounded-lg border border-border bg-surface/50 overflow-hidden",style:{containerType:"inline-size"},children:[m("div",{className:["px-3 py-2 flex items-center justify-between min-w-0",l?"cursor-pointer hover:bg-surface":""].join(" "),onClick:l?()=>c(u=>!u):void 0,children:[o("span",{className:"text-xs font-semibold text-foreground min-w-0 break-words",children:qe(e.label,s)}),l&&o("span",{className:"text-foreground-subtle text-xs shrink-0 ml-2",children:i?"▸":"▾"})]}),!i&&o("div",{className:"px-3 pb-3 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3",children:e.fields.map(u=>o(kr,{field:u,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a},u.key))})]})})}function Ib({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i}){const[c,l]=M(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} min-w-0`,children:[e.label&&o("div",{className:pn,children:qe(e.label,s)}),m("div",{className:"@container rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden",style:{containerType:"inline-size"},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-1 @[480px]: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(kr,{field:p,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:i},g)})},d.id))]})]})}function Tb({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 Ks={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 Db(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 Lb({field:e}){const t=Ks[e.variant??"info"]??Ks.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:Db(e.content)}}):o("p",{className:"text-xs text-foreground-subtle leading-relaxed whitespace-pre-line",children:e.content})]})})}var Zs={ok:"bg-success",warn:"bg-amber-500",danger:"bg-danger",idle:"bg-foreground-subtle/40",unknown:"bg-foreground-subtle/40"};function Ob(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 $b(e){return!Number.isFinite(e)||e<=0?"—":new Date(e).toLocaleTimeString()}function Bb({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 ${Zs[String(t).toLowerCase()]??Zs.unknown}`}),o("span",{children:String(t)})]}):e==="duration"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:Ob(t)}):e==="timestamp"&&typeof t=="number"?o("span",{className:"font-mono text-[11px]",children:$b(t)}):o("span",{children:String(t)})}function Fb({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(Bb,{kind:a.kind,value:n[a.key]})},a.key))},s))})]})})]})}function zb({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,w)=>{const k=c.slice();k[y]={...k[y]??{},[x]:w},r(k)},p=y=>{c.length<=l||r(c.filter((x,w)=>w!==y))},h=()=>{if(c.length>=u)return;const y=e.defaultItem??{};r([...c,{...y}])},g=(y,x)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(w,k)=>{const S=y[k];return S==null||S===""?"—":String(S)}):`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(Fi,{className:"h-3 w-3"}),"Remove"]})]}),o("div",{className:"grid grid-cols-1 @[480px]:grid-cols-2 gap-x-3 gap-y-2 p-3",children:e.itemFields.map(w=>o(kr,{field:w,values:y,onChange:(k,S)=>d(x,k,S),disabled:n,translationFn:s,onTestField:a,allFields:e.itemFields,onAction:i},w.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(Yt,{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 Gb({field:e,disabled:t,onAction:r}){const[n,s]=M(!1),a=un(),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(Ee,{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 oc(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 Qb({field:e,value:t,values:r,onChange:n,disabled:s,onAction:a}){const[i,c]=M(!1),[l,u]=M(null),[d,p]=M(null),h=oc(e,r),g=Object.keys(e.paramsFromForm??{}).some(x=>h[x]===void 0);Z(()=>{if(!a||g){p(null),u(null);return}let x=!1;return c(!0),u(null),a(e.action,e.key,h).then(w=>{if(x)return;const k=w;let S=[];if(Array.isArray(k))S=k;else if(k&&typeof k=="object")for(const N of Object.keys(k)){const E=k[N];if(Array.isArray(E)){S=E;break}}p(S)}).catch(w=>{x||(u(w instanceof Error?w.message:String(w)),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(Ee,{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(w=>{const k=w[b];return k===""||k===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:w=>n(w.target.value),children:[!x&&o("option",{value:"",children:"— Select —"}),(d??[]).map((w,k)=>{const S=w[b],N=w[v],E=y?w[y]:void 0,D=typeof S=="string"&&S!==""?S:`row-${k}`;return m("option",{value:typeof S=="string"?S:String(S??""),children:[typeof N=="string"?N:String(N??D),E!==void 0?` (${String(E)})`:""]},D)})]})})()})}function jb({field:e,values:t,disabled:r,onAction:n}){const[s,a]=M(!1),[i,c]=M(null),l=un(),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=oc(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(Ee,{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 Ub({field:e}){const t=kg();return o(fb,{widgetId:e.widgetId,host:"device-tab",config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})}function Hb(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 Vb({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=Hb(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(Ee,{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(qb,{action:h,fieldKey:s,value:i,onAction:r},h.action))})]})})}function Wb({name:e}){const t="h-3.5 w-3.5";switch(e){case"copy":return o(vt,{className:t});case"refresh-cw":return o(an,{className:t});case"external-link":return o(Di,{className:t});case"trash-2":return o(Xe,{className:t});case"download":return o(Zn,{className:t});case"upload":return o(Ui,{className:t});default:return o(Do,{className:t})}}function qb({action:e,fieldKey:t,value:r,onAction:n}){const s=un(),[a,i]=M(!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(Wb,{name:e.icon})})}function Kb(e){return"multiple"in e&&e.multiple!=null}function Zb({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=S=>r(e.key,[...S]),y=(S,N)=>{const E=[...g];E[S]=N,v(E)},x=()=>{g.length>=p||v([...g,b])},w=S=>{g.length<=d||v(g.filter((N,E)=>E!==S))},k=()=>{const{multiple:S,...N}=e;return{...N,...{label:void 0,description:void 0,required:!1}}};return o(Ee,{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((S,N)=>{const E=u.itemLabel?.replace("${n}",String(N+1));return m("div",{className:"space-y-1",children:[E&&o("div",{className:pn,children:E}),m("div",{className:"flex items-center gap-2",children:[o("div",{className:"flex-1 min-w-0",children:o(kr,{field:k(),values:{...t,[e.key]:S},onChange:(D,C)=>y(N,C),disabled:n,translationFn:s,onTestField:a,onAction:l,allFields:c})}),g.length>d&&o("button",{type:"button",onClick:()=>w(N),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(Xe,{className:"h-3.5 w-3.5"})})]})]},N)}),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(Yt,{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 Yb(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 kr({field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,externalProbe:i,allFields:c,onAction:l}){if(Kb(e))return o(Zb,{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(Vb,{field:e,values:t,onAction:l,translationFn:s});if(!Yb(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=wg(e.type);switch(e.type){case"text":return o(vb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"number":return o(yb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"boolean":return o(xb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"select":return o(wb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"multiselect":return o(kb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"password":return o(Nb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"textarea":return o(Sb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"slider":return o(Cb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"tags":return o(Mb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"color":return o(Pb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"node-select":return o(Eb,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"node-multiselect":return o(Ab,{field:e,value:d,onChange:p,disabled:n,translationFn:s});case"probe":return o(Rb,{field:e,value:d,onChange:p,disabled:n,translationFn:s,onTestField:a,onAction:l,externalProbe:i});case"group":return o(_b,{field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a});case"sub-tabs":return o(Ib,{field:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,onAction:l});case"separator":return o(Tb,{});case"info":return o(Lb,{field:e});case"object-array":return o(Fb,{field:e});case"editable-array":return o(zb,{field:e,value:d,onChange:p,disabled:n,translationFn:s,onTestField:a,onAction:l});case"button":return o(Gb,{field:e,disabled:n,onAction:l});case"addon-action-select":return o(Qb,{field:e,value:d,values:t,onChange:p,disabled:n,onAction:l});case"addon-action-button":return o(jb,{field:e,values:t,disabled:n,onAction:l});case"widget":return o(Ub,{field:e});default:return h?o(h,{field:e,value:d,onChange:p,disabled:n}):null}}function Xb(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function qe(e,t){if(e!==void 0)return t&&Xb(e)?t(e):e}function Jb({section:e,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,probeResults:i}){const[c,l]=M(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 @[480px]: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(kr,{field:h,values:t,onChange:r,disabled:n,translationFn:s,onTestField:a,externalProbe:i?.[h.key]},h.key))})]})}function ev({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(Jb,{section:u,values:t,onChange:l,disabled:n,translationFn:s,onTestField:a,probeResults:i},u.id))})}var tv=({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 Ys(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 rv(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 mE({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]=M(null),[b,v]=M(!0),[y,x]=M(null),[w,k]=M(!1),[S,N]=M(l??!1),[E,D]=M({}),[C,_]=M(null);Z(()=>{_(null),D({})},[e,t,r,i,p]),Z(()=>{let V=!1;v(!0),x(null);const Y=p==="override"&&Object.keys(E).length>0?E:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:r,...Y?{overlay:Y}:{}}).then(K=>{V||(g(K),Y||_(Ys(K)),v(!1))}).catch(K=>{V||(x(K instanceof Error?K.message:String(K)),v(!1))}),()=>{V=!0}},[e,t,r,i,p,JSON.stringify(E)]);const O=X(()=>Ys(h),[h]),ae=X(()=>h?rv(h):null,[h]),de=async V=>{if(p==="override"){const K=C??O,R={};for(const L of Object.keys(V))V[L]!==K[L]&&(R[L]=V[L]);const T={...K,...R};D(R),d?.(R,T);return}const Y={};for(const K of Object.keys(V))V[K]!==O[K]&&(Y[K]=V[K]);if(Object.keys(Y).length!==0){k(!0);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:r,patch:Y}),g(await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:r})),a?.()}catch(K){x(K instanceof Error?K.message:String(K))}finally{k(!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 le=p==="override"?{...O,...E}:O,W=m(ve,{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(ev,{schema:ae,values:le,onChange:de,disabled:s===!0||w})]});return c===!0?m("section",{className:"rounded-lg border border-border bg-surface overflow-hidden",children:[m("button",{type:"button",onClick:()=>N(V=>!V),className:"w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left","aria-expanded":S,children:[o(tv,{open:S}),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:S?"hide":"edit"})]}),S?o("div",{className:"border-t border-border px-4 py-3",children:W}):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:W})]}):o("div",{children:W})}function nv({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(ov,{phase:n}),u&&o(sv,{raw:t}),l&&o(av,{motion:e}),d&&o(iv,{detections:r.detections,frameWidth:r.frameWidth,frameHeight:r.frameHeight})]})}function ov({phase:e}){const t=ja(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 sv({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:o(ve,{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 av({motion:e}){return e.frameWidth===0||e.frameHeight===0?null:o(ve,{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 iv({detections:e,frameWidth:t,frameHeight:r}){return t===0||r===0?null:o(ve,{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 lv(){return typeof window>"u"?!1:window.matchMedia("(hover: none) and (pointer: coarse)").matches||typeof navigator<"u"&&navigator.maxTouchPoints>0||"ontouchstart"in window}function cv(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 uv=1500,dv=15e3,pv=40;function fv({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,handleOffer:h,getIceServers:g,addIceCandidate:b,getIceCandidates:v,closeSession:y,hintsOverride:x}){const w=J(null),k=J(null),S=J(null),N=J(new Set),E=J(null),D=J(null),C=J(0),_=J(!0),[O,ae]=M("idle"),[de,le]=M(""),[W,V]=M(s),[Y,K]=M(!1),[R,T]=M(!1),L=lv(),[z,B]=M(!0),ee=J(null),P=J(!1);(p||d)&&(P.current=!0);const F=P.current,U=J(!1);h&&(U.current=!0);const q=U.current,se=I(H=>{ae(H),c?.(H)},[c]),te=I(()=>{if(E.current?.abort(),E.current=null,D.current&&(clearTimeout(D.current),D.current=null),S.current&&(S.current.close(),S.current=null),y&&N.current.size>0){for(const H of N.current)y(H).catch(()=>{});N.current.clear()}w.current&&(w.current.srcObject=null)},[y]),_e=I(async()=>{if(!_.current||!d||!p)return;te(),se("connecting");const H=new AbortController;E.current=H;try{const{sessionId:re,sdpOffer:j,iceServers:ie}=await d({...cv(k.current),...x});if(N.current.add(re),!_.current||H.signal.aborted){y?.(re).catch(()=>{}),N.current.delete(re);return}const $=new RTCPeerConnection({iceServers:[...ie??[],{urls:"stun:stun.l.google.com:19302"}]});S.current=$;const pe=new MediaStream;$.ontrack=ye=>{console.debug("[WebRTC] ontrack",ye.track.kind,ye.track.readyState),pe.addTrack(ye.track),w.current&&(w.current.srcObject=pe,w.current.play().catch(()=>{}))},$.oniceconnectionstatechange=()=>{if(!_.current)return;const ye=$.iceConnectionState;console.debug("[WebRTC] ICE state:",ye),ye==="connected"||ye==="completed"?(C.current=0,se("playing"),w.current?.paused&&(console.debug("[WebRTC] video was paused at ICE connected — calling play()"),w.current.play().catch(()=>{}))):(ye==="failed"||ye==="disconnected"||ye==="closed")&&(se("disconnected"),Oe())},$.onicecandidateerror=ye=>{console.debug("[WebRTC] ICE candidate error:",ye)},console.debug("[WebRTC] Setting remote description (server offer)..."),await $.setRemoteDescription({type:"offer",sdp:j});const ue=await $.createAnswer();if(await $.setLocalDescription(ue),console.debug("[WebRTC] Local description set, waiting for ICE gathering..."),await Xs($),!_.current)return;const fe=($.localDescription?.sdp??"").split(`
77
+ `).filter(ye=>ye.startsWith("a=candidate:")).length;console.debug("[WebRTC] Sending answer to server",{localCandidates:fe,sessionId:re.slice(0,8)}),await p(re,$.localDescription?.sdp??""),console.debug("[WebRTC] Answer sent successfully");const ze=$,xe=()=>{const ye=ze.connectionState;if(ye==="closed"||ye==="failed")return;const Jt=w.current;Jt&&Jt.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${ze.iceConnectionState})`)};setTimeout(xe,3e3),setTimeout(xe,8e3)}catch(re){if(!_.current)return;const j=re instanceof Error?re.message:String(re);le(j),se("error"),l?.(j),Oe()}},[e,t,d,p,te,se,l,x]),Ie=I(async()=>{if(_.current){te(),se("connecting");try{const H=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]});S.current=H,H.addTransceiver("video",{direction:"recvonly"}),H.addTransceiver("audio",{direction:"recvonly"});const re=new MediaStream;H.ontrack=ue=>{re.addTrack(ue.track),w.current&&(w.current.srcObject=re,w.current.play().catch(()=>{}))},H.oniceconnectionstatechange=()=>{if(!_.current)return;const ue=H.iceConnectionState;ue==="connected"||ue==="completed"?(C.current=0,se("playing"),w.current?.paused&&w.current.play().catch(()=>{})):(ue==="failed"||ue==="disconnected"||ue==="closed")&&(se("disconnected"),Oe())};const j=await H.createOffer();if(await H.setLocalDescription(j),await Xs(H),!_.current)return;const ie=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,$=await fetch(ie,{method:"POST",headers:{"Content-Type":"application/sdp"},body:H.localDescription?.sdp??""});if(!$.ok)throw new Error(`WHEP ${$.status}: ${$.statusText}`);const pe=await $.text();await H.setRemoteDescription({type:"answer",sdp:pe})}catch(H){if(!_.current)return;const re=H instanceof Error?H.message:String(H);le(re),se("error"),l?.(re),Oe()}}},[e,t,te,se,l]),Se=I(async()=>{if(!_.current||!h)return;te(),se("connecting");const H=new AbortController;E.current=H;try{const re=await g?.();if(!_.current||H.signal.aborted)return;const j=new RTCPeerConnection({iceServers:[...re??[],{urls:"stun:stun.l.google.com:19302"}]});S.current=j;const ie=new MediaStream;j.ontrack=xe=>{console.debug("[WebRTC] ontrack (client-offer)",xe.track.kind,xe.track.readyState),ie.addTrack(xe.track),w.current&&(w.current.srcObject=ie,w.current.play().catch(()=>{}))},j.oniceconnectionstatechange=()=>{if(!_.current)return;const xe=j.iceConnectionState;console.debug("[WebRTC] ICE state (client-offer):",xe),xe==="connected"||xe==="completed"?(C.current=0,se("playing"),w.current?.paused&&w.current.play().catch(()=>{})):(xe==="failed"||xe==="disconnected"||xe==="closed")&&(se("disconnected"),Oe())};let $=null;const pe=[];j.onicecandidate=xe=>{if(!xe.candidate)return;const ye=xe.candidate.toJSON();$&&b?b($,ye).catch(()=>{}):pe.push(ye)},j.addTransceiver("video",{direction:"recvonly"}),j.addTransceiver("audio",{direction:"recvonly"});const ue=await j.createOffer();if(await j.setLocalDescription(ue),!_.current||H.signal.aborted)return;const{sessionId:fe,sdpAnswer:ze}=await h(j.localDescription?.sdp??ue.sdp??"");if($=fe,N.current.add(fe),!_.current||H.signal.aborted){y?.(fe).catch(()=>{}),N.current.delete(fe);return}if(b)for(const xe of pe)b(fe,xe).catch(()=>{});if(pe.length=0,await j.setRemoteDescription({type:"answer",sdp:ze}),console.debug("[WebRTC] Client-offer answer set (trickle)",{sessionId:fe.slice(0,8)}),v){const xe=new Set,ye=Date.now(),Jt=async()=>{if(!(!_.current||H.signal.aborted||S.current!==j)){try{const{candidates:Sc,done:Cc}=await v(fe);for(const Vo of Sc){const fn=Vo.candidate??"";fn&&!xe.has(fn)&&(xe.add(fn),j.addIceCandidate(new RTCIceCandidate(Vo)).catch(()=>{}))}const Ho=j.iceConnectionState;if(Cc||Date.now()-ye>1e4||Ho==="connected"||Ho==="completed")return}catch{}setTimeout(()=>{Jt()},200)}};Jt()}}catch(re){if(!_.current)return;const j=re instanceof Error?re.message:String(re);le(j),se("error"),l?.(j),Oe()}},[h,g,b,v,y,te,se,l]),we=q?Se:F?_e:Ie,Le=J(()=>{});Le.current=we;const Oe=I(()=>{if(!_.current||C.current>=pv)return;const H=C.current;C.current+=1;const re=Math.min(dv,uv*2**H),j=Math.round(re*(.8+Math.random()*.4));D.current=setTimeout(()=>{_.current&&Le.current()},j)},[]);Z(()=>(_.current=!0,C.current=0,n&&we(),()=>{_.current=!1,te()}),[e,t]);const at=J(!1);Z(()=>{if(n){if(q){if(!h)return}else if(F){if(!d||!p)return}else return;at.current||S.current||(at.current=!0,we())}},[n,q,F,h,d,p,we]);const Ke=()=>{C.current=0,we()},Ue=()=>{w.current&&(w.current.muted=!w.current.muted,V(w.current.muted))},it=async()=>{if(k.current)try{if(document.fullscreenElement){await document.exitFullscreen();return}if(k.current.requestFullscreen){await k.current.requestFullscreen();return}const H=w.current;H?.webkitEnterFullscreen&&H.webkitEnterFullscreen()}catch(H){console.warn(`Fullscreen toggle failed: ${H instanceof Error?H.message:H}`)}},tt=async()=>{const H=w.current;if(H)try{const re=Reflect.get(H,"webkitSetPresentationMode");if(typeof re=="function"){const j=Reflect.get(H,"webkitPresentationMode");re.call(H,j==="picture-in-picture"?"inline":"picture-in-picture");return}document.pictureInPictureElement?await document.exitPictureInPicture():await H.requestPictureInPicture()}catch(re){console.warn(`PiP toggle failed: ${re instanceof Error?re.message:String(re)}`)}},rt=()=>{if(!w.current)return;const H=document.createElement("canvas");H.width=w.current.videoWidth||1280,H.height=w.current.videoHeight||720;const re=H.getContext("2d");if(!re)return;re.drawImage(w.current,0,0);const j=document.createElement("a");j.download=`${t.replace(/[/:]/g,"-")}-${Date.now()}.jpg`,j.href=H.toDataURL("image/jpeg",.92),j.click()};Z(()=>{const H=()=>K(!!document.fullscreenElement);document.addEventListener("fullscreenchange",H);const re=w.current;return re?.addEventListener("webkitbeginfullscreen",H),re?.addEventListener("webkitendfullscreen",H),()=>{document.removeEventListener("fullscreenchange",H),re?.removeEventListener("webkitbeginfullscreen",H),re?.removeEventListener("webkitendfullscreen",H)}},[]),Z(()=>{const H=w.current,re=typeof document<"u"&&document.pictureInPictureEnabled===!0,j=H!==null&&typeof Reflect.get(H,"webkitSetPresentationMode")=="function";T(re||j)},[]);const Q=()=>{L||(B(!0),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>B(!1),3e3))},be=()=>{B(H=>!H),ee.current&&clearTimeout(ee.current)};return m("div",{ref:k,className:`relative isolate bg-black overflow-hidden group ${i}`,onMouseMove:Q,onMouseEnter:Q,onTouchStart:be,children:[o("video",{ref:w,autoPlay:n,muted:W,playsInline:!0,className:"w-full h-full object-contain relative z-0"}),r&&O==="playing"&&o("div",{className:"absolute top-2 left-2 z-10 transform-gpu px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium",children:r}),u,O==="connecting"&&m("div",{className:"absolute inset-0 z-10 transform-gpu 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…"})]}),(O==="error"||O==="disconnected")&&m("div",{className:"absolute inset-0 z-10 transform-gpu 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:O==="error"?de||"Connection failed":"Disconnected"}),o("button",{onClick:Ke,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&&O!=="idle"&&O!=="error"&&m("div",{className:`absolute bottom-0 inset-x-0 z-20 transform-gpu flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${L||z?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,children:[o("div",{className:"flex items-center gap-1",children:o(Lr,{onClick:Ue,title:W?"Unmute":"Mute",children:W?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(Lr,{onClick:rt,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"})]})}),R&&o(Lr,{onClick:tt,title:"Picture-in-Picture",children:m("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o("path",{d:"M21 9V6a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2h4"}),o("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"})]})}),o(Lr,{onClick:it,title:Y?"Exit fullscreen":"Fullscreen",children:Y?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 Lr({onClick:e,title:t,children:r}){return o("button",{onClick:e,title:t,className:"rounded-full p-1.5 min-w-[44px] min-h-[44px] flex items-center justify-center text-white/80 hover:text-white hover:bg-white/20 active:bg-white/30 transition-colors",children:r})}async function Xs(e){if(e.iceGatheringState!=="complete")return new Promise(t=>{let r=!1,n;const s=()=>{r||(r=!0,n&&clearInterval(n),e.removeEventListener("icegatheringstatechange",a),t())},a=()=>{e.iceGatheringState==="complete"&&s()};e.addEventListener("icegatheringstatechange",a);const i=Date.now();n=setInterval(()=>{const c=e.localDescription?.sdp??"";/ typ host/.test(c)&&Date.now()-i>=600&&s()},100),setTimeout(s,2500)})}function mv(e){return e==="streaming"?"bg-emerald-500":e==="connecting"?"bg-amber-500":e==="error"?"bg-rose-500":"bg-zinc-500"}function hv(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 mo({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 gv({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 bv({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 vv({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 Bn({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 sc({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 yv({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 hE({serverUrl:e,createSession:t,sendAnswer:r,handleOffer:n,getIceServers:s,addIceCandidate:a,getIceCandidates:i,closeSession:c,streams:l,activeStreamId:u,onStreamChange:d,deviceName:p,phase:h,pipelineMetrics:g,detections:b,defaultShowDetections:v=!0,defaultShowMotion:y=!1,streamStats:x,autoPlay:w=!1,showPlayStop:k=!1,snapshotSrc:S,snapshotLoading:N=!1,onRefreshSnapshot:E,showStreamStats:D=!1,children:C,extraOverlay:_,ptzAvailable:O=!1,ptzShown:ae=!1,ptzOverlay:de,onPtzToggle:le,intercomAvailable:W=!1,intercomShown:V=!1,onIntercomToggle:Y,chromeless:K=!1,className:R}){const T=Hg(),[L,z]=M(w),[B,ee]=M(v),[P,F]=M(y),[U,q]=M(null),[se,te]=M(!1),_e=J(null);Z(()=>{if(!se)return;function j(ie){_e.current&&!_e.current.contains(ie.target)&&te(!1)}return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[se]);const Ie=u??U??l?.[0]?.id??"",Se=l?.find(j=>j.id===Ie)??l?.[0],we=Se?.inputFps!=null?{status:Se.status??"unknown",inputFps:Se.inputFps,bitrateKbps:Se.bitrateKbps??0}:null,Le=j=>{q(j),d?.(j),L&&k&&(z(!1),setTimeout(()=>z(!0),50))},Oe=X(()=>{const j=Se?.target;if(j)return ie=>t(j,ie)},[t,Se]),at=X(()=>{const j=Se?.target;if(!(!j||!n))return ie=>n(j,ie)},[n,Se]),Ke=l,Ue=()=>z(!0),it=()=>z(!1),tt=g?.phase??h,rt=tt==="active",Q=!!b,be=Q&&(B||P),H=O&&ae&&!!de,re=k?L:!0;return m("div",{className:`overflow-hidden ${K?"":"rounded-xl border border-border bg-surface"} ${R??""}`,children:[m("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b border-border",children:[m("div",{className:"flex items-center gap-2 min-w-0",children:[(x??we)&&o("span",{className:`shrink-0 w-2 h-2 rounded-full ${mv((x??we).status)}`}),p&&o("span",{className:"text-xs font-medium text-foreground truncate",children:p}),Ke&&Ke.length>1&&m("div",{className:"relative",children:[o("select",{"data-testid":"stream-profile-select",value:Ie,onChange:j=>Le(j.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:Ke.map(j=>o("option",{value:j.id,children:j.label},j.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 shrink-0 ml-auto",children:[W&&m("button",{"data-testid":"stream-intercom-toggle","data-intercom-shown":V?"true":"false",onClick:Y,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${V?"bg-primary/15 text-primary":"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:V?"Close intercom":"Open intercom",children:[o(bv,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:"Intercom"})]}),T.map(j=>{const ie=j.tone==="primary"?"bg-primary text-primary-foreground":"bg-primary/15 text-primary";return m("button",{type:"button","data-toolbar-button-id":j.id,"data-toolbar-button-active":j.active?"true":"false",onClick:j.onClick,disabled:j.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${j.active?ie:"text-foreground-subtle hover:text-foreground hover:bg-surface-hover"}`,title:j.title??j.label,children:[j.icon,o("span",{className:"hidden xl:inline",children:j.label})]},j.id)}),k&&m("button",{"data-testid":"stream-play-toggle","data-stream-playing":re?"true":"false",onClick:re?it:Ue,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${re?"bg-danger/10 text-danger hover:bg-danger/20":"bg-primary/10 text-primary hover:bg-primary/20"}`,title:re?"Stop stream":"Start stream",children:[re?o(gv,{className:"h-3 w-3"}):o(mo,{className:"h-3 w-3"}),o("span",{className:"hidden xl:inline",children:re?"Stop":"Play"})]}),E&&m("button",{"data-testid":"stream-snapshot-refresh",onClick:E,disabled:N,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(sc,{className:`h-3 w-3 ${N?"animate-spin":""}`}),o("span",{className:"hidden xl:inline",children:"Snapshot"})]}),(Q||O||g||tt||x||we&&we.inputFps>0)&&m("div",{ref:_e,className:"relative",children:[o("button",{onClick:()=>te(j=>!j),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(vv,{className:"h-3.5 w-3.5"})}),se&&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:[D&&x&&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"]})]}),m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Decode"}),m("span",{className:"tabular-nums text-foreground",children:[x.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:hv(x.uptimeMs)})]})]}),!D&&we&&we.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:[we.inputFps.toFixed(1)," fps"]})]}),we.bitrateKbps>0&&m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Bitrate"}),m("span",{className:"tabular-nums text-foreground",children:[we.bitrateKbps," kbps"]})]})]}),(g||Q&&tt)&&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 ${rt?"text-red-400":"text-emerald-400"}`,children:[o("span",{className:`w-1.5 h-1.5 rounded-full ${rt?"bg-red-500 animate-pulse":"bg-emerald-500"}`}),rt?"Active":"Watching"]})]}),g&&g.detectionFps>0&&m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Detection"}),m("span",{className:"tabular-nums text-foreground",children:[g.detectionFps.toFixed(1)," det/s"]})]}),g&&g.avgInferenceMs>0&&m("div",{className:"flex justify-between gap-3",children:[o("span",{children:"Inference"}),m("span",{className:"tabular-nums text-foreground",children:[g.avgInferenceMs.toFixed(0)," ms"]})]})]}),Q&&m(ve,{children:[o(Bn,{label:"Show detections",active:B,onClick:()=>ee(j=>!j)}),o(Bn,{label:"Show motion",active:P,onClick:()=>F(j=>!j)})]}),O&&o(Bn,{label:"PTZ controls",active:ae,onClick:()=>{le?.(),te(!1)}})]})]})]})]}),re?o("div",{className:"aspect-video relative",children:o(fv,{serverUrl:e,streamKey:Ie,autoPlay:!0,className:"w-full h-full",createSession:Oe,sendAnswer:r,handleOffer:at,getIceServers:s,addIceCandidate:a,getIceCandidates:i,closeSession:c,overlay:be||_||H?m(ve,{children:[be&&o(nv,{detections:b,showPhaseIndicator:!1,showMotionZones:P,showMotionRaw:P,showDetections:B}),_,H&&de]}):void 0},Ie)}):o(xv,{src:S??null,isLoading:N,onPlay:Ue,onRetry:E,extraOverlay:_||H?m(ve,{children:[_,H&&de]}):null,suppressPlayHover:!!_||H}),C]})}function xv({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(mo,{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(yv,{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(sc,{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(mo,{className:"h-3 w-3"}),"Play Live"]})]})]})})}var Js={value:"auto",label:"Auto (best available)"};function wv(e){return e.charAt(0).toUpperCase()+e.slice(1)}function gE({deviceId:e,value:t,onChange:r,disabled:n,label:s,className:a}){const i=Ct(),c=Cg({deviceId:e},{refetchOnWindowFocus:!1}),[l,u]=M([Js]);Z(()=>{if(!c.data)return;const h=`${e}/`,g=[Js];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:wv(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(en,{"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 kv=Object.defineProperty,nn=Object.getOwnPropertySymbols,ac=Object.prototype.hasOwnProperty,ic=Object.prototype.propertyIsEnumerable,ea=(e,t,r)=>t in e?kv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ho=(e,t)=>{for(var r in t||(t={}))ac.call(t,r)&&ea(e,r,t[r]);if(nn)for(var r of nn(t))ic.call(t,r)&&ea(e,r,t[r]);return e},go=(e,t)=>{var r={};for(var n in e)ac.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&nn)for(var n of nn(e))t.indexOf(n)<0&&ic.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 Mt;(e=>{const t=class he{constructor(l,u,d,p){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<he.MIN_VERSION||l>he.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 he.encodeSegments(d,u)}static encodeBinary(l,u){const d=e.QrSegment.makeBytes(l);return he.encodeSegments([d],u)}static encodeSegments(l,u,d=1,p=40,h=-1,g=!0){if(!(he.MIN_VERSION<=d&&d<=p&&p<=he.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let b,v;for(b=d;;b++){const k=he.getNumDataCodewords(b,u)*8,S=i.getTotalBits(l,b);if(S<=k){v=S;break}if(b>=p)throw new RangeError("Data too long")}for(const k of[he.Ecc.MEDIUM,he.Ecc.QUARTILE,he.Ecc.HIGH])g&&v<=he.getNumDataCodewords(b,k)*8&&(u=k);let y=[];for(const k of l){r(k.mode.modeBits,4,y),r(k.numChars,k.mode.numCharCountBits(b),y);for(const S of k.getData())y.push(S)}s(y.length==v);const x=he.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 k=236;y.length<x;k^=253)r(k,8,y);let w=[];for(;w.length*8<y.length;)w.push(0);return y.forEach((k,S)=>w[S>>>3]|=k<<7-(S&7)),new he(b,u,w,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!=he.getNumDataCodewords(u,d))throw new RangeError("Invalid argument");const p=he.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u],h=he.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u],g=Math.floor(he.getNumRawDataModules(u)/8),b=p-g%p,v=Math.floor(g/p);let y=[];const x=he.reedSolomonComputeDivisor(h);for(let k=0,S=0;k<p;k++){let N=l.slice(S,S+v-h+(k<b?0:1));S+=N.length;const E=he.reedSolomonComputeRemainder(N,x);k<b&&N.push(0),y.push(N.concat(E))}let w=[];for(let k=0;k<y[0].length;k++)y.forEach((S,N)=>{(k!=v-h||N>=b)&&w.push(S[k])});return s(w.length==g),w}drawCodewords(l){if(l.length!=Math.floor(he.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+=he.PENALTY_N1:b>5&&l++):(this.finderPenaltyAddHistory(b,v),g||(l+=this.finderPenaltyCountPatterns(v)*he.PENALTY_N3),g=this.modules[h][y],b=1);l+=this.finderPenaltyTerminateAndCount(g,b,v)*he.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+=he.PENALTY_N1:b>5&&l++):(this.finderPenaltyAddHistory(b,v),g||(l+=this.finderPenaltyCountPatterns(v)*he.PENALTY_N3),g=this.modules[y][h],b=1);l+=this.finderPenaltyTerminateAndCount(g,b,v)*he.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+=he.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*he.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<he.MIN_VERSION||l>he.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(he.getNumRawDataModules(l)/8)-he.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*he.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]=he.reedSolomonMultiply(u[h],d),h+1<u.length&&(u[h]^=u[h+1]);d=he.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]^=he.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 ke{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 ke(ke.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!ke.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 ke(ke.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!ke.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=ke.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d))*45;p+=ke.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d+1)),r(p,11,u)}return d<l.length&&r(ke.ALPHANUMERIC_CHARSET.indexOf(l.charAt(d)),6,u),new ke(ke.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:ke.isNumeric(l)?[ke.makeNumeric(l)]:ke.isAlphanumeric(l)?[ke.makeAlphanumeric(l)]:[ke.makeBytes(ke.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 ke(ke.Mode.ECI,0,u)}static isNumeric(l){return ke.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return ke.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})(Mt||(Mt={}));(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={}))})(Mt||(Mt={}));(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={}))})(Mt||(Mt={}));var Bt=Mt;/**
82
+ * @license qrcode.react
83
+ * Copyright (c) Paul O'Shannessy
84
+ * SPDX-License-Identifier: ISC
85
+ */var Nv={L:Bt.QrCode.Ecc.LOW,M:Bt.QrCode.Ecc.MEDIUM,Q:Bt.QrCode.Ecc.QUARTILE,H:Bt.QrCode.Ecc.HIGH},lc=128,cc="L",uc="#FFFFFF",dc="#000000",pc=!1,fc=1,Sv=4,Cv=0,Mv=.1;function mc(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 hc(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 Ev(e,t,r,n){if(n==null)return null;const s=e.length+r*2,a=Math.floor(t*Mv),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 Av(e,t){return t!=null?Math.max(Math.floor(t),0):e?Sv:Cv}function gc({value:e,level:t,minVersion:r,includeMargin:n,marginSize:s,imageSettings:a,size:i,boostLevel:c}){let l=Ce.useMemo(()=>{const g=(Array.isArray(e)?e:[e]).reduce((b,v)=>(b.push(...Bt.QrSegment.makeSegments(v)),b),[]);return Bt.QrCode.encodeSegments(g,Nv[t],r,void 0,void 0,c)},[e,t,r,c]);const{cells:u,margin:d,numCells:p,calculatedImageSettings:h}=Ce.useMemo(()=>{let g=l.getModules();const b=Av(n,s);return{cells:g,margin:b,numCells:g.length+b*2,calculatedImageSettings:Ev(g,i,b,a)}},[l,i,a,n,s]);return{qrcode:l,margin:d,cells:u,numCells:p,calculatedImageSettings:h}}var Pv=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Rv=Ce.forwardRef(function(t,r){const n=t,{value:s,size:a=lc,level:i=cc,bgColor:c=uc,fgColor:l=dc,includeMargin:u=pc,minVersion:d=fc,boostLevel:p,marginSize:h,imageSettings:g}=n,b=go(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=b,y=go(b,["style"]),x=g?.src,w=Ce.useRef(null),k=Ce.useRef(null),S=Ce.useCallback(le=>{w.current=le,typeof r=="function"?r(le):r&&(r.current=le)},[r]),[N,E]=Ce.useState(!1),{margin:D,cells:C,numCells:_,calculatedImageSettings:O}=gc({value:s,level:i,minVersion:d,boostLevel:p,includeMargin:u,marginSize:h,imageSettings:g,size:a});Ce.useEffect(()=>{if(w.current!=null){const le=w.current,W=le.getContext("2d");if(!W)return;let V=C;const Y=k.current,K=O!=null&&Y!==null&&Y.complete&&Y.naturalHeight!==0&&Y.naturalWidth!==0;K&&O.excavation!=null&&(V=hc(C,O.excavation));const R=window.devicePixelRatio||1;le.height=le.width=a*R;const T=a/_*R;W.scale(T,T),W.fillStyle=c,W.fillRect(0,0,_,_),W.fillStyle=l,Pv?W.fill(new Path2D(mc(V,D))):C.forEach(function(L,z){L.forEach(function(B,ee){B&&W.fillRect(ee+D,z+D,1,1)})}),O&&(W.globalAlpha=O.opacity),K&&W.drawImage(Y,O.x+D,O.y+D,O.w,O.h)}}),Ce.useEffect(()=>{E(!1)},[x]);const ae=ho({height:a,width:a},v);let de=null;return x!=null&&(de=Ce.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{E(!0)},ref:k,crossOrigin:O?.crossOrigin})),Ce.createElement(Ce.Fragment,null,Ce.createElement("canvas",ho({style:ae,height:a,width:a,ref:S,role:"img"},y)),de)});Rv.displayName="QRCodeCanvas";var bc=Ce.forwardRef(function(t,r){const n=t,{value:s,size:a=lc,level:i=cc,bgColor:c=uc,fgColor:l=dc,includeMargin:u=pc,minVersion:d=fc,boostLevel:p,title:h,marginSize:g,imageSettings:b}=n,v=go(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:y,cells:x,numCells:w,calculatedImageSettings:k}=gc({value:s,level:i,minVersion:d,boostLevel:p,includeMargin:u,marginSize:g,imageSettings:b,size:a});let S=x,N=null;b!=null&&k!=null&&(k.excavation!=null&&(S=hc(x,k.excavation)),N=Ce.createElement("image",{href:b.src,height:k.h,width:k.w,x:k.x+y,y:k.y+y,preserveAspectRatio:"none",opacity:k.opacity,crossOrigin:k.crossOrigin}));const E=mc(S,y);return Ce.createElement("svg",ho({height:a,width:a,viewBox:`0 0 ${w} ${w}`,ref:r,role:"img"},v),!!h&&Ce.createElement("title",null,h),Ce.createElement("path",{fill:c,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),Ce.createElement("path",{fill:l,d:E,shapeRendering:"crispEdges"}),N)});bc.displayName="QRCodeSVG";var _v=192;function Iv({value:e,size:t=_v,className:r,alt:n}){const s=e.trim();return s.length===0?null:o("div",{className:A("inline-flex rounded-md bg-white p-2",r),children:o(bc,{value:s,size:t,marginSize:1,title:n??"QR code"})})}var Tv=2e3;function Dv({value:e,label:t,className:r,disabled:n}){const[s,a]=M(!1),i=I(()=>{e&&navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),Tv)})},[e]);return m(St,{size:"sm",variant:"ghost",type:"button",disabled:n||e.length===0,onClick:i,className:A(r),"aria-label":s?"Copied":`Copy ${t??"value"}`,children:[s?o(qt,{className:"h-3.5 w-3.5 text-success"}):o(vt,{className:"h-3.5 w-3.5"}),t?o("span",{className:"ml-1",children:s?"Copied":t}):null]})}var Lv=wo(zc),Ov=Uc({id:Wo(),stableId:wt(),addonId:wt(),type:wt(),name:wt(),online:hn(),disabled:hn(),parentDeviceId:Wo().nullable(),role:wt().nullable().optional(),features:wo(wt()).optional(),isCamera:hn().optional()}),$v=wo(wt()),ta=1e4;function Bv(e){return e==="linked"?"success":e==="error"?"danger":"warning"}function Fv(e){return e==="linked"?"Linked":e==="unlinked"?"Unlinked":e==="error"?"Error":e}function zv({field:e}){const[t,r]=M(!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(St,{size:"sm",variant:"ghost",type:"button","aria-label":t?"Hide value":"Reveal value",onClick:()=>r(a=>!a),children:t?o(Io,{className:"h-3.5 w-3.5"}):o(Zt,{className:"h-3.5 w-3.5"})}),o(Dv,{value:e.value,label:e.label})]})}function Gv({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(xf,{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(Iv,{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(zv,{field:r},r.label))})]})]})]})}function Qv({addonId:e,deviceId:t,exposed:r,busy:n,onExpose:s,onUnexpose:a}){return o(St,{size:"sm",variant:r?"ghost":"primary",disabled:n,onClick:c=>{c.stopPropagation(),!n&&(r?a(t):s(t))},title:r?`Stop exposing to "${e}"`:`Expose to "${e}"`,children:r?m(ve,{children:[o(Lf,{className:"mr-1 h-3.5 w-3.5"}),"Exposed"]}):m(ve,{children:[o(Jn,{className:"mr-1 h-3.5 w-3.5"}),"Expose"]})})}function yE({addonId:e,trpc:t,onOpenDevice:r}){const n=xr(),s=Mg({nodeId:"hub",addonId:e},{refetchInterval:ta,retry:!1}),a=Ag({nodeId:"hub",addonId:e},{refetchInterval:ta,retry:!1}),i=Eg({nodeId:"hub",addonId:e},{retry:!1}),c=Kl({},{refetchInterval:5e3}),l=I(()=>{n.invalidateQueries({queryKey:[["deviceExport"]]})},[n]),u=Pg({onSuccess:l}),d=Rg({onSuccess:l}),p=X(()=>{const O=Bc.safeParse(s.data);return O.success?O.data:null},[s.data]),h=X(()=>{const O=Lv.safeParse(a.data);return O.success?O.data:[]},[a.data]),g=X(()=>new Set(h.map(O=>O.deviceId)),[h]),b=X(()=>{const O=$v.safeParse(i.data);return new Set(O.success?O.data:[])},[i.data]),v=X(()=>[...b].sort(),[b]),y=X(()=>{const O=c.data;if(!Array.isArray(O))return[];const ae=[];for(const de of O){const le=Ov.safeParse(de);le.success&&b.has(le.data.type)&&ae.push(le.data)}return ae},[c.data,b]),x=p?.linkState??"unlinked",w=s.isLoading||a.isLoading||i.isLoading||c.isLoading,k=p?.exposedDeviceCount??g.size,S=u.isPending||d.isPending,N=I(O=>{u.mutate({deviceId:O,nodeId:"hub",addonId:e})},[u,e]),E=I(O=>{d.mutate({deviceId:O,nodeId:"hub",addonId:e})},[d,e]),D=I(O=>{const ae=String(O.id);return o(Qv,{addonId:e,deviceId:ae,exposed:g.has(ae),busy:S,onExpose:N,onUnexpose:E})},[e,g,S,N,E]),C=I(O=>r?.(String(O)),[r]),_=v.length>0;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(Jn,{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(Qt,{variant:Bv(x),children:Fv(x)}),m("span",{className:"text-[11px] text-foreground-subtle",children:[k," exposed"]})]}),w&&o(Fe,{className:"h-3.5 w-3.5 animate-spin text-foreground-subtle"})]}),p?.error&&o("div",{className:"px-4 py-3 border-b border-border",children:o(Sm,{message:p.error})}),p?.setup&&o(Gv,{setup:p.setup}),o("div",{className:"p-3",children:_&&y.length>0?o(Nh,{devices:y,trpc:t,defaultView:"table",filters:{types:v},urlScope:"nested",lsKey:`device-export:${e}`,onNavigate:r?C:void 0,renderRowAction:D}):o(km,{icon:Jn,title:"No exportable devices",description:_?`No devices of the supported kinds (${v.join(", ")}) are available to expose to "${e}".`:`"${e}" reports no exportable device kinds yet.`})})]})}function xE({samples:e,sampleRate:t=16e3,height:r=96,className:n="",color:s="#3b82f6",bgColor:a="transparent"}){const i=J(null),c=J(null),l=I(()=>{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 w=Math.floor(x*v),k=Math.min(Math.floor((x+1)*v),e.length);let S=0,N=0;for(let _=w;_<k;_++){const O=e[_];O<S&&(S=O),O>N&&(N=O)}const E=y-N*y,D=y-S*y,C=Math.max(1,D-E);b.fillRect(x,E,1,C)}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]);Z(()=>{l()},[l]),Z(()=>{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 wE({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=J(null),d=J(null),[p,h]=M([]);Z(()=>{e!==null&&h(v=>{const y=[...v,{dbfs:e,timestamp:Date.now()}];return y.length>r?y.slice(-r):y})},[e,r]);const g=I(()=>{const v=u.current,y=d.current;if(!v||!y)return;const x=y.clientWidth;if(x===0)return;const w=window.devicePixelRatio||1;v.width=x*w,v.height=n*w,v.style.width=`${x}px`,v.style.height=`${n}px`;const k=v.getContext("2d");if(!k||(k.scale(w,w),k.clearRect(0,0,x,n),p.length===0))return;const S=p[p.length-1].timestamp,N=t*1e3,E=S-N,D=p.filter(ae=>ae.timestamp>=E);if(D.length===0)return;const C=Math.max(1,Math.floor(x/(t*2))),_=Math.abs(l);for(const ae of D){const de=ae.timestamp-E,le=Math.floor(de/N*x),W=(Math.max(l,Math.min(0,ae.dbfs))-l)/_,V=Math.max(1,W*n);k.fillStyle=ae.dbfs>=c?i:a,k.globalAlpha=.8,k.fillRect(le,n-V,C,V)}k.globalAlpha=1;const O=n-(c-l)/_*n;k.strokeStyle=i,k.globalAlpha=.25,k.lineWidth=1,k.setLineDash([4,4]),k.beginPath(),k.moveTo(0,O),k.lineTo(x,O),k.stroke(),k.setLineDash([]),k.globalAlpha=1},[p,t,n,a,i,c,l]);Z(()=>{g()},[g]),Z(()=>{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 jv(e){return e>=.8?"bg-emerald-500":e>=.5?"bg-amber-500":e>=.3?"bg-orange-500":"bg-zinc-500"}function Uv(e){return e>=.8?"text-emerald-400":e>=.5?"text-amber-400":e>=.3?"text-orange-400":"text-zinc-400"}function kE({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 ${jv(c.score)}`,style:{width:`${u}%`}})}),m("span",{className:`text-xs font-mono font-semibold w-14 text-right ${Uv(c.score)}`,children:[(c.score*100).toFixed(1),"%"]})]},`${c.className}-${l}`)})})]})}function NE({data:e,label:t="Response",className:r=""}){const[n,s]=M(!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 Hv={Activity:ut,Eye:Zt,AlertTriangle:Xt,PauseCircle:ef,PowerOff:yf};function SE({phase:e,...t}){const r=Hv[ja(e).icon];return o(r,{...t})}function cr(e){const[t,r]=M([]),n=I(a=>{r(i=>{const c=[...i,a];return c.length>e?c.slice(-e):c})},[e]),s=I(()=>{r([])},[]);return X(()=>({entries:t,append:n,reset:s}),[t,n,s])}function ra(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 na={error:{icon:Kt,color:"text-red-400"},warn:{icon:Xt,color:"text-amber-400"},info:{icon:pf,color:"text-blue-400"},debug:{icon:Vp,color:"text-gray-500"}},oa={debug:0,info:1,warn:2,error:3},Vv=["all","debug","info","warn","error"],Wv=500;function qv(e,t){return t?(oa[e]??0)>=(oa[t]??0):!0}function vc({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]=M(""),[v,y]=M(""),[x,w]=M(a),k=e,S=t??(g||void 0),N=r??(v?Number(v):void 0),E=n,D=s,C=X(()=>{const Q={};return k&&(Q.agentId=k),S&&(Q.addonId=S),N!==void 0&&Number.isFinite(N)&&(Q.deviceId=N),E&&(Q.integrationId=E),D&&(Q.requestId=D),Object.keys(Q).length>0?Q:void 0},[k,S,N,E,D]),_=cr(Wv),O=d??_,ae=O.entries,[de,le]=M(0),[W,V]=M(!0),[Y,K]=M(!1),[R,T]=M(!1),[L,z]=M(new Set),[B,ee]=M(""),P=J(null),F=`${k??""}:${S??""}:${String(N??"")}:${E??""}:${D??""}`,U=J(F);Z(()=>{U.current!==F&&(U.current=F,O.reset(),le(0),z(new Set),K(!1))},[F,O]);const{data:q,isLoading:se}=f.logs.query.useQuery({...C?{tags:C}:{},limit:u},{staleTime:3e4});f.logs.subscribe.useSubscription({...C?{tags:C}:{}},{onData:Q=>{O.append(Q)}});const te=X(()=>{const Q=(q??[]).map(ie=>({timestamp:ie.timestamp,level:ie.level,message:ie.message,scope:ie.scope,tags:ie.tags,meta:ie.meta})),be=new Map;for(const ie of Q)be.set(`${ie.timestamp}|${ie.level}|${ie.scope??""}|${ie.message}`,ie);for(const ie of ae)be.set(`${ie.timestamp}|${ie.level}|${ie.scope??""}|${ie.message}`,ie);const H=[...be.values()].sort((ie,$)=>new Date(ie.timestamp).getTime()-new Date($.timestamp).getTime()),re=(de>0?H.filter(ie=>new Date(ie.timestamp).getTime()>de):H).filter(ie=>qv(ie.level,x)),j=B.trim().toLowerCase();return j?re.filter(ie=>{if(ie.message.toLowerCase().includes(j)||ie.scope&&ie.scope.toLowerCase().includes(j))return!0;if(ie.tags){for(const $ of Object.values(ie.tags))if($!==void 0&&String($).toLowerCase().includes(j))return!0}if(ie.meta){for(const $ of Object.values(ie.meta))if($!=null&&ra($).toLowerCase().includes(j))return!0}return!1}):re},[q,ae,x,de,B]),_e=J(te.length);Z(()=>{const Q=P.current,be=te.length>_e.current;_e.current=te.length,!(!Q||!be||!W)&&Q.scrollTo({top:Q.scrollHeight})},[te.length,W]);const Ie=I(()=>{const Q=P.current;if(!Q)return;const be=Q.scrollHeight-Q.scrollTop-Q.clientHeight<32;V(H=>H===be?H:be)},[]),Se=X(()=>te.filter(Q=>Q.tags&&Object.keys(Q.tags).length>0||Q.meta&&Object.keys(Q.meta).length>0).map(Q=>`${Q.timestamp}|${Q.level}|${Q.scope??""}|${Q.message}`),[te]),we=I(()=>{K(Q=>(Q&&z(new Set),!Q))},[]),Le=I(()=>{const Q=te.map(be=>{const H=new Date(be.timestamp).toLocaleTimeString(),re=be.tags?" "+Object.entries(be.tags).filter(([,j])=>j).map(([j,ie])=>`${j}=${ie}`).join(" "):"";return`${H} [${be.level.toUpperCase()}]${be.scope?` [${be.scope}]`:""}${re} ${be.message}`});navigator.clipboard.writeText(Q.join(`
86
+ `)).then(()=>{T(!0),setTimeout(()=>T(!1),1500)})},[te]),Oe=f.logs.clear.useMutation(),at=I(()=>{le(Date.now()),O.reset(),Oe.mutate({...C?{tags:C}:{}})},[O,Oe,C]),Ke=I(Q=>{z(be=>{const H=new Set(be);return H.has(Q)?H.delete(Q):H.add(Q),H})},[]),[Ue,it]=M(null),tt=I((Q,be)=>{const H=new Date(Q.timestamp).toISOString(),re=Q.tags?" "+Object.entries(Q.tags).filter(([,$])=>$).map(([$,pe])=>`${$}=${pe}`).join(" "):"",j=Q.meta&&Object.keys(Q.meta).length>0?` meta=${JSON.stringify(Q.meta)}`:"",ie=`${H} [${Q.level.toUpperCase()}]${Q.scope?` [${Q.scope}]`:""}${re} ${Q.message}${j}`;navigator.clipboard.writeText(ie).then(()=>{it(be),setTimeout(()=>it($=>$===be?null:$),1200)})},[]),rt=I(Q=>`${Q.timestamp}|${Q.level}|${Q.scope??""}|${Q.message}`,[]);return m("div",{className:A("h-full min-h-0 flex flex-col",h),onClick:Q=>Q.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"}),k&&o(Fn,{label:"agent",value:k}),S&&o(Fn,{label:"addon",value:S}),N!==void 0&&o(Fn,{label:"device",value:`#${N}`}),o("div",{className:"flex rounded border border-border overflow-hidden text-[9px]",children:Vv.map(Q=>m("button",{type:"button",onClick:()=>w(Q==="all"?void 0:Q),className:A("px-1.5 py-0.5 capitalize transition-colors",Q==="all"&&!x||x===Q?"bg-primary/10 text-primary":"text-foreground-subtle hover:bg-surface-hover",Q!=="all"&&"border-l border-border"),children:[Q,Q!=="all"?"+":""]},Q))}),o(Or,{icon:Op,label:W?"Following":"Paused",active:W,onClick:()=>{V(Q=>{const be=!Q;return be&&P.current&&P.current.scrollTo({top:P.current.scrollHeight,behavior:"smooth"}),be})}}),o(Or,{icon:Y?Kp:Zp,label:Y?"Collapse":"Expand",active:Y,onClick:we,disabled:Se.length===0}),o(Or,{icon:vt,label:R?"Copied!":"Copy",onClick:Le,disabled:te.length===0}),o(Or,{icon:Xe,label:"Clear",onClick:at}),m("div",{className:"relative",children:[o("input",{type:"text",value:B,onChange:Q=>ee(Q.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"}),B&&o("button",{type:"button",onClick:()=>ee(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Re,{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(Re,{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:Q=>b(Q.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:Q=>y(Q.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:P,onScroll:Ie,className:A("flex-1 min-h-0 overflow-auto font-mono text-[10px]",i),children:[se&&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..."]}),!se&&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(Q=>{const be=na[Q.level]??na.info,H=be.icon,re=rt(Q),j=Y||L.has(re),ie=Q.tags&&Object.keys(Q.tags).length>0,$=Q.meta&&Object.keys(Q.meta).length>0,pe=ie||$;return m("tr",{className:A("hover:bg-surface-hover/30 border-b border-border/30",pe&&"cursor-pointer"),onClick:pe?()=>Ke(re):void 0,children:[o("td",{className:"px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]",children:new Date(Q.timestamp).toLocaleTimeString()}),o("td",{className:A("px-1 py-1 align-top w-5",be.color),children:o(H,{className:"h-3 w-3"})}),c&&o("td",{className:"px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]",title:Q.scope,children:Q.scope?.replace(/^addon:/,"")??""}),o("td",{className:"px-2 py-1 text-foreground break-all",children:m("div",{className:"flex items-start gap-1",children:[pe&&(j?o(gt,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"}):o(bt,{className:"h-3 w-3 text-foreground-subtle shrink-0 mt-0.5"})),m("div",{className:"flex-1 min-w-0",children:[Q.message,j&&pe&&m("div",{className:"mt-0.5 pl-3 text-[9px] leading-snug",children:[$&&Object.entries(Q.meta).filter(([,ue])=>ue!==void 0&&ue!=="").map(([ue,fe])=>m("div",{className:"break-all",children:[o("span",{className:"text-amber-400/80",children:ue}),o("span",{className:"text-foreground-subtle",children:"="}),o("span",{className:"text-foreground",children:ra(fe)})]},`m-${ue}`)),ie&&Object.entries(Q.tags).filter(([,ue])=>ue!==void 0).map(([ue,fe])=>m("div",{className:"break-all",children:[o("span",{className:"text-primary/70",children:ue}),o("span",{className:"text-foreground-subtle",children:"="}),o("span",{className:"text-foreground",children:fe})]},`t-${ue}`))]})]})]})}),o("td",{className:"px-1 py-1 align-top w-5",children:o(Kv,{copied:Ue===re,onCopy:()=>tt(Q,re)})})]},re)})})})]})]})}function CE({position:e="bottom",className:t,...r}){return o("div",{className:A(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(vc,{maxHeight:"max-h-48",...r})})}function Fn({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 Kv({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this row",onClick:r=>{r.stopPropagation(),t()},className:A("rounded p-0.5 transition-colors",e?"text-emerald-400":"text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover"),children:e?o(qt,{className:"h-3 w-3"}):o(vt,{className:"h-3 w-3"})})}function Or({icon:e,label:t,onClick:r,disabled:n,active:s}){return m("button",{type:"button",onClick:r,disabled:n,className:A("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 Zv(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 Yv={[ce.AddonStarted]:{icon:Xn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Started"},[ce.AddonInstalled]:{icon:Zn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Installed"},[ce.AddonRestarted]:{icon:an,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Restarted"},[ce.AddonUpdated]:{icon:Ui,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Updated"},[ce.AddonStopped]:{icon:eo,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Stopped"},[ce.AddonUninstalled]:{icon:Xe,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"Uninstalled"},[ce.AddonCrashed]:{icon:Kt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Crashed"},[ce.AddonError]:{icon:Xt,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Error"},[ce.DetectionPhaseTransition]:{icon:ut,color:"bg-violet-500/15 text-violet-400 border-violet-500/30",label:"Phase"},[ce.DetectionResult]:{icon:Nf,color:"bg-purple-500/15 text-purple-400 border-purple-500/30",label:"Detection"},[ce.DetectionEvent]:{icon:Zt,color:"bg-blue-500/15 text-blue-400 border-blue-500/30",label:"Event"},[ce.DetectionCameraNative]:{icon:bs,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Camera AI"},[ce.ProviderMotion]:{icon:vs,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[ce.MotionOnMotionChanged]:{icon:vs,color:"bg-orange-500/15 text-orange-400 border-orange-500/30",label:"Motion"},[ce.MotionAnalysis]:{icon:ut,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion analysis"},[ce.MotionZonesRaw]:{icon:ut,color:"bg-orange-500/10 text-orange-300 border-orange-500/20",label:"Motion zones"},[ce.ProviderDetection]:{icon:bs,color:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",label:"Provider Det"},[ce.PipelineAudioInferenceResult]:{icon:Bi,color:"bg-pink-500/15 text-pink-400 border-pink-500/30",label:"Audio"},[ce.AgentOnline]:{icon:Xn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Agent Online"},[ce.AgentOffline]:{icon:eo,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Agent Offline"},[ce.DeviceRegistered]:{icon:Zn,color:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",label:"Registered"},[ce.DeviceUnregistered]:{icon:Xe,color:"bg-red-500/15 text-red-400 border-red-500/30",label:"Unregistered"},[ce.DeviceStateChanged]:{icon:ut,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:"State"}};function bo(e,t){const r=Yv[e]??{icon:Xn,color:"bg-foreground-subtle/10 text-foreground-subtle border-border",label:e.split(".").pop()??e};if(e===ce.DeviceStateChanged&&t&&typeof t.capName=="string"){const n=t.capName;return{...r,label:n}}return r}var Dt=Object.freeze([...new Set(Object.values(ce))].sort()),Xv=Object.freeze([ce.PipelineCameraMetricsSnapshot,ce.PipelineRunnerLoadSnapshot,ce.PipelineEngineMetricsSnapshot,ce.PipelineInferenceResult,ce.PipelineTrace,ce.PipelineProgress,ce.StreamBrokerMetricsSnapshot,ce.MetricsNodeResourcesSnapshot,ce.MetricsNodeProcessesSnapshot,ce.ClusterTopologySnapshot,ce.MotionAnalysis,ce.MotionZonesRaw,ce.DetectionResult,ce.PipelineAudioInferenceResult,ce.PlatformProbePhase,ce.BenchmarkProgress,ce.ModelDownloadProgress]),Jv=new Set(Xv),ey=Object.freeze(Dt.filter(e=>!Jv.has(e)));function Wr(e,t){if(e===ce.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===ce.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===ce.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===ce.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===ce.ProviderMotion)return t.active===!0?"motion start":"motion stop";if(e===ce.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===ce.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===ce.ProviderDetection||e===ce.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 ty(e){const t=e.category;return t===ce.DetectionResult||t===ce.PipelineAudioInferenceResult?Wr(t,e.data)!==null:!0}var ry=300;function yc({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=X(()=>n??s??ey,[n,s]),b=X(()=>[...g].sort().join(","),[g]),[v,y]=M(()=>new Set(g)),x=J(b);Z(()=>{x.current!==b&&(x.current=b,y(new Set(g)))},[b,g]);const w=cr(ry),k=d??w,S=k.entries,[N,E]=M(!0),[D,C]=M(new Set),[_,O]=M(""),[ae,de]=M(!1),[le,W]=M(""),[V,Y]=M(0),K=J(null),R=J(null),T=`${e??""}:${t??""}:${String(r??"")}:${a??""}`,L=J(T);Z(()=>{L.current!==T&&(L.current=T,k.reset(),C(new Set),Y(0))},[T,k]),Z(()=>{if(!ae)return;const $=pe=>{const ue=R.current;ue&&pe.target instanceof Node&&!ue.contains(pe.target)&&de(!1)};return document.addEventListener("mousedown",$),()=>{document.removeEventListener("mousedown",$)}},[ae]);const z=X(()=>{const $={};return e&&($.agentId=e),t&&($.addonId=t),r!==void 0&&($.deviceId=r),a&&($.category=a),$},[e,t,r,a]),B=X(()=>[...v].sort(),[v]),ee=X(()=>{const $={...z,limit:c};return B.length>0&&B.length<Dt.length&&($.category=B),$},[z,c,X(()=>B.join(","),[B]),B]),{data:P,isLoading:F}=f.systemEvents.getRecent.useQuery(ee,{staleTime:3e4}),U=J(v);Z(()=>{U.current=v},[v]);const q=z;f.systemEvents.subscribe.useSubscription(q,{onData:$=>{const pe=$;pe?.id&&Zv(pe,e,t,r)&&U.current.has(pe.category)&&k.append(pe)}});const se=J(S.length);Z(()=>{const $=K.current;if(!$){se.current=S.length;return}const pe=se.current;if(se.current=S.length,!(S.length<=pe)){if(N&&$.scrollTop<=8)$.scrollTo({top:0});else if(!N&&$.scrollTop>0){const ue=$.firstElementChild?.firstElementChild,fe=ue instanceof HTMLElement?ue.offsetHeight:28;$.scrollTop+=fe*(S.length-pe)}}},[S.length,N]);const te=X(()=>{const $=new Map;for(const fe of P??[])$.set(fe.id,fe);for(const fe of S)$.set(fe.id,fe);let pe=[...$.values()].filter(fe=>v.has(fe.category)).filter(ty);V>0&&(pe=pe.filter(fe=>new Date(fe.timestamp).getTime()>V));const ue=_.trim().toLowerCase();return ue&&(pe=pe.filter(fe=>{if(fe.category.toLowerCase().includes(ue)||bo(fe.category,fe.data).label.toLowerCase().includes(ue))return!0;const ze=Wr(fe.category,fe.data);if(ze&&ze.toLowerCase().includes(ue))return!0;try{if(new Date(fe.timestamp).toLocaleTimeString().toLowerCase().includes(ue))return!0}catch{}try{if(JSON.stringify(fe.data).toLowerCase().includes(ue)||JSON.stringify(fe.source).toLowerCase().includes(ue))return!0}catch{}return!1})),pe.sort((fe,ze)=>new Date(ze.timestamp).getTime()-new Date(fe.timestamp).getTime())},[P,S,v,_,V]),_e=I($=>{C(pe=>{const ue=new Set(pe);return ue.has($)?ue.delete($):ue.add($),ue})},[]),Ie=I($=>{y(pe=>{const ue=new Set(pe);return ue.has($)?ue.delete($):ue.add($),ue})},[]),Se=I(()=>{y(new Set(g)),O(""),Y(0)},[g]),we=I(()=>{Y(Date.now()),k.reset()},[k]),[Le,Oe]=M(!1),[at,Ke]=M(null),Ue=I($=>{const pe=new Date($.timestamp).toISOString(),ue=Wr($.category,$.data)??"",fe=ue?` ${ue}`:"";return`${pe} [${$.category}]${fe} data=${JSON.stringify($.data)}`},[]),it=I(()=>{const $=te.map(Ue);navigator.clipboard.writeText($.join(`
87
+ `)).then(()=>{Oe(!0),setTimeout(()=>Oe(!1),1500)})},[te,Ue]),tt=I($=>{navigator.clipboard.writeText(Ue($)).then(()=>{Ke($.id),setTimeout(()=>Ke(pe=>pe===$.id?null:pe),1200)})},[Ue]),rt=I(()=>{y(new Set(Dt))},[]),Q=I(()=>{y(new Set)},[]),be=X(()=>{const $=le.trim().toLowerCase();return $?Dt.filter(pe=>pe.toLowerCase().includes($)):Dt},[le]),H=Dt.length,re=v.size,j=re===H,ie=j?"All":`${re}/${H}`;return m("div",{className:A("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($r,{label:"agent",value:e}),t&&o($r,{label:"addon",value:t}),r!==void 0&&o($r,{label:"device",value:`#${r}`}),a&&o($r,{label:"category",value:a}),m("button",{type:"button",onClick:()=>{E($=>!$),!N&&K.current&&K.current.scrollTo({top:0,behavior:"smooth"})},className:A("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",N?"border-border text-foreground-subtle hover:text-foreground":"border-amber-500/30 bg-amber-500/10 text-amber-400"),children:[o(zp,{className:"h-2.5 w-2.5"}),N?"Auto":"Paused"]}),l&&m("div",{className:"relative",ref:R,children:[m("button",{type:"button",onClick:()=>de($=>!$),className:A("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",j?"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(Li,{className:"h-2.5 w-2.5"}),"Filter (",ie,")"]}),ae&&o(ny,{search:le,onSearchChange:W,categories:be,active:v,onToggle:Ie,onSelectAll:rt,onSelectNone:Q,onResetDefaults:Se})]}),m("button",{type:"button",onClick:Se,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(Gi,{className:"h-2.5 w-2.5"}),"Reset"]}),m("button",{type:"button",onClick:we,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(Xe,{className:"h-2.5 w-2.5"}),"Clear"]}),m("button",{type:"button",onClick:it,disabled:te.length===0,className:A("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",Le?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",te.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy all visible events",children:[o(vt,{className:"h-2.5 w-2.5"}),Le?"Copied!":"Copy"]}),m("div",{className:"relative",children:[o("input",{type:"text",value:_,onChange:$=>O($.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"}),_&&o("button",{type:"button",onClick:()=>O(""),className:"absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground",title:"Clear search",children:o(Re,{className:"h-2.5 w-2.5"})})]}),S.length>0&&m("span",{className:"text-[9px] text-emerald-400 font-medium",children:["+",S.length," live"]})]}),p&&o("button",{type:"button",onClick:p,className:"text-foreground-subtle hover:text-foreground",children:o(Re,{className:"h-3.5 w-3.5"})})]}),m("div",{ref:K,className:A("flex-1 min-h-0 overflow-auto text-[10px]",i),children:[F&&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..."]}),!F&&te.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle",children:"No events found"}),te.length>0&&o("div",{className:"divide-y divide-border/30",children:te.map($=>{const pe=bo($.category,$.data),ue=pe.icon,fe=Wr($.category,$.data),ze=D.has($.id);return m("div",{className:"flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer",onClick:()=>_e($.id),children:[o("span",{className:"text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5",children:new Date($.timestamp).toLocaleTimeString()}),o(oy,{copied:at===$.id,onCopy:()=>tt($)}),m("div",{className:"flex-1 min-w-0",children:[m("div",{className:"flex items-center gap-1.5",children:[ze?o(gt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(bt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}),m("span",{className:A("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium",pe.color),children:[o(ue,{className:"h-2.5 w-2.5"}),pe.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})]}),fe&&o("p",{className:"text-foreground-subtle text-[10px] mt-0.5 ml-5",children:fe}),ze&&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(([xe,ye])=>m("div",{children:[o("span",{className:"text-primary/70",children:xe}),o("span",{className:"text-foreground-subtle",children:": "}),o("span",{className:"text-foreground break-all",children:typeof ye=="object"?JSON.stringify(ye):String(ye)})]},xe))]})]})]},$.id)})})]})]})}function ny({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(hr,{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(Re,{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=bo(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:A("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 ME({position:e="bottom",className:t,...r}){return o("div",{className:A(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(yc,{maxHeight:"max-h-48",...r})})}function $r({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 oy({copied:e,onCopy:t}){return o("button",{type:"button",title:"Copy this event",onClick:r=>{r.stopPropagation(),t()},className:A("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(qt,{className:"h-3 w-3"}):o(vt,{className:"h-3 w-3"})})}function EE({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]=M(null),{available:p,adopted:h}=X(()=>{const k=s.data??[],S=E=>typeof E.metadata.rtspChannel=="number"?E.metadata.rtspChannel:Number.POSITIVE_INFINITY,N=(E,D)=>{const C=S(E),_=S(D);return C!==_?C-_:E.name.localeCompare(D.name)};return{available:k.filter(E=>!E.alreadyAdopted).sort(N),adopted:k.filter(E=>E.alreadyAdopted).sort(N)}},[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(k){d(k.childNativeId);try{await c.mutateAsync({deviceId:e,childNativeId:k.childNativeId})}finally{d(null)}}async function w(k){if(k.adoptedDeviceId!=null){d(k.childNativeId);try{await l.mutateAsync({deviceId:e,childDeviceId:k.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(an,{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(Xt,{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(ve,{children:[p.length>0?o(sa,{title:"Available to add",count:p.length,tone:"primary",children:p.map(k=>o(aa,{child:k,busy:u===k.childNativeId,onAdopt:x,onRelease:w,onOpenChild:r},k.childNativeId))}):null,h.length>0?o(sa,{title:"Already adopted",count:h.length,tone:"muted",children:h.map(k=>o(aa,{child:k,busy:u===k.childNativeId,onAdopt:x,onRelease:w,onOpenChild:r},k.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 sa({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 aa({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(sy,{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(Di,{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(Xe,{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(Yt,{className:"h-3.5 w-3.5"}),"Add"]})]})}function sy({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(Hi,{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(To,{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(Of,{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(_i,{className:"h-2.5 w-2.5"})," unknown"]})}}function ay(e,t){if(!e||typeof e!="object")return null;const r=e;if(r.category!==ce.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 iy(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var ly=Object.freeze([...new Set(Qc.filter(e=>e.scope==="device").map(e=>e.name))].sort()),cy=1;function uy({deviceId:e,defaultCaps:t,maxHeight:r="max-h-96",onClose:n,className:s}){const[a,i]=M(X(()=>new Set(t??[]),[t])),[c,l]=M(""),[u,d]=M(!1),[p,h]=M(""),g=J(null),[b,v]=M(new Map),[y,x]=M(new Map),[,w]=M(0),k=J(e);Z(()=>{k.current!==e&&(k.current=e,v(new Map),x(new Map))},[e]);const{data:S,isLoading:N}=f.deviceState.getAllSnapshots.useQuery({},{staleTime:3e4}),E=J(!1);Z(()=>{if(E.current||!iy(S))return;const P=S[String(e)];if(E.current=!0,!P)return;const F=Date.now();v(U=>{const q=new Map(U);for(const[se,te]of Object.entries(P))q.has(se)||q.set(se,{slice:te,updatedAt:F});return q})},[S,e]),Z(()=>{E.current=!1},[e]),f.systemEvents.subscribe.useSubscription({deviceId:e,category:ce.DeviceStateChanged},{onData:P=>{const F=ay(P,e);F&&v(U=>{const q=new Map(U);return q.set(F.capName,{slice:F.slice,updatedAt:Date.now()}),q})}}),Z(()=>{const P=setInterval(()=>w(F=>F+1),5e3);return()=>clearInterval(P)},[]);const D=X(()=>{const P=new Set(ly);for(const F of b.keys())P.add(F);return[...P].sort()},[b]),C=X(()=>{const P=c.trim().toLowerCase();return[...b.keys()].sort().filter(F=>a.size>0&&!a.has(F)?!1:!P||F.toLowerCase().includes(P)?!0:yo(b.get(F)?.slice??{},P))},[b,a,c]),_=I(P=>{i(F=>{const U=new Set(F);return U.has(P)?U.delete(P):U.add(P),U})},[]),O=I(()=>{i(new Set(t??[])),l("")},[t]),ae=I(()=>{i(new Set(D))},[D]),de=I(()=>{i(new Set)},[]),le=I((P,F)=>{x(U=>{const q=new Map(U);return q.set(P,!F),q})},[]),W=I((P,F)=>{const U=y.get(P);return U!==void 0?U:F<cy},[y]),[V,Y]=M(!1),K=I(()=>{const P={};for(const F of C){const U=b.get(F);U&&(P[F]=U.slice)}navigator.clipboard.writeText(JSON.stringify(P,null,2)).then(()=>{Y(!0),setTimeout(()=>Y(!1),1500)})},[C,b]),R=X(()=>{const P=p.trim().toLowerCase();return P?D.filter(F=>F.toLowerCase().includes(P)):D},[p,D]),T=D.length,L=a.size,z=L===0||L===T,B=z?"All":`${L}/${T}`;Z(()=>{if(!u)return;const P=F=>{const U=g.current;U&&!U.contains(F.target)&&d(!1)};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[u]);const ee=c.trim().toLowerCase();return m("div",{className:A("h-full min-h-0 flex flex-col",s),onClick:P=>P.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(hy,{label:"device",value:`#${e}`}),m("div",{className:"relative",ref:g,children:[m("button",{type:"button",onClick:()=>d(P=>!P),className:A("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",z?"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(Li,{className:"h-2.5 w-2.5"}),"Filter (",B,")"]}),u&&o(gy,{search:p,onSearchChange:h,caps:R,active:a,onToggle:_,onSelectAll:ae,onSelectNone:de,onResetDefaults:O})]}),m("button",{type:"button",onClick:O,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(Gi,{className:"h-2.5 w-2.5"}),"Reset"]}),m("button",{type:"button",onClick:K,disabled:C.length===0,className:A("inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors",V?"border-emerald-500/30 bg-emerald-500/10 text-emerald-400":"border-border text-foreground-subtle hover:text-foreground",C.length===0&&"opacity-40 cursor-not-allowed"),title:"Copy visible state as JSON",children:[o(vt,{className:"h-2.5 w-2.5"}),V?"Copied!":"Copy"]}),m("div",{className:"relative",children:[o("input",{type:"text",value:c,onChange:P=>l(P.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(Re,{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(Re,{className:"h-3.5 w-3.5"})})]}),m("div",{className:A("flex-1 min-h-0 overflow-auto text-[10px] font-mono",r),children:[N&&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..."]}),!N&&b.size===0&&o("div",{className:"py-4 text-center text-foreground-subtle font-sans",children:"No runtime state"}),!N&&b.size>0&&C.length===0&&o("div",{className:"py-4 text-center text-foreground-subtle font-sans",children:"No caps match the filter"}),C.length>0&&o("div",{className:"py-1",children:C.map(P=>{const F=b.get(P);return F?o(dy,{capName:P,slice:F.slice,updatedAt:F.updatedAt,searchNeedle:ee,isPathOpen:W,onToggle:le},P):null})})]})]})}function dy({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(kc,{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 ",my(r)]})]}),c&&o("div",{children:l.length===0?o(wc,{depth:1,label:"empty slice"}):l.map(([u,d])=>o(xc,{path:`${i}.${u}`,nodeKey:u,value:d,depth:1,searchNeedle:n,isPathOpen:s,onToggle:a},u))})]})}function xc({path:e,nodeKey:t,value:r,depth:n,searchNeedle:s,isPathOpen:a,onToggle:i}){const c=py(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:A("shrink-0",zn(t,s,"text-primary/70")),children:t}),o("span",{className:"text-foreground-subtle",children:":"}),o("span",{className:A("break-all",zn(vo(r),s,fy(r))),children:vo(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(kc,{open:u,hasChildren:c.entries.length>0}),o("span",{className:zn(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(wc,{depth:n+1,label:c.kind==="array"?"empty array":"empty object"}):c.entries.map(([d,p])=>o(xc,{path:`${e}.${d}`,nodeKey:d,value:p,depth:n+1,searchNeedle:s,isPathOpen:a,onToggle:i},d)))]})}function wc({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 kc({open:e,hasChildren:t}){return t?e?o(gt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o(bt,{className:"h-3 w-3 text-foreground-subtle shrink-0"}):o("span",{className:"inline-block w-3 shrink-0"})}function py(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 vo(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 fy(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 zn(e,t,r){return t&&e.toLowerCase().includes(t)?A(r,"bg-violet-500/20 rounded px-0.5"):r}function yo(e,t){if(Array.isArray(e))return e.some(r=>yo(r,t));if(e&&typeof e=="object"){for(const[r,n]of Object.entries(e))if(r.toLowerCase().includes(t)||yo(n,t))return!0;return!1}return vo(e).toLowerCase().includes(t)}function my(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 hy({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 gy({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(hr,{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(Re,{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 Gn=500,by=[{id:"logs",label:"Logs",icon:Sf},{id:"events",label:"Events",icon:sn},{id:"state",label:"State",icon:sf}];function AE({deviceId:e,defaultEventCategories:t,defaultStateCaps:r,initialTab:n="events",className:s,maxHeight:a="max-h-96"}){const[i,c]=M(n),l=cr(Gn),u=cr(Gn),d=cr(Gn),p=l.reset,h=u.reset,g=d.reset;return Z(()=>{p(),h(),g()},[e,p,h,g]),m("div",{className:A("flex flex-col h-full min-h-0",s),children:[o("div",{className:"flex items-center gap-1 mb-2 shrink-0",children:by.map(({id:b,label:v,icon:y})=>m("button",{type:"button",onClick:()=>c(b),className:A("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(vc,{deviceId:e,maxHeight:a,showFilters:!1,liveBuffer:l}),i==="events"&&o(yc,{deviceId:e,defaultCategories:t,maxHeight:a,showCategoryFilter:!0,liveBuffer:u}),i==="state"&&o(uy,{deviceId:e,defaultCaps:r,maxHeight:a,liveBuffer:d})]})]})}function PE({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]=M(!1),[b,v]=M(!1),[y,x]=M(null),w=async()=>{x(null),v(!0);try{const k=await d();p?.(k),g(!1)}catch(k){x(k instanceof Error?k.message:String(k))}finally{v(!1)}};return m(ve,{children:[m(St,{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(qf,{open:h,onOpenChange:k=>!b&&g(k),children:m(Xi,{children:[m(Zf,{children:[m(Xf,{className:"flex items-center gap-2",children:[o(Xt,{className:"h-4 w-4 text-amber-400"}),r]}),typeof n=="string"?o(Jf,{children:n}):n]}),y&&o("div",{className:A("mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10","text-xs text-danger"),children:y}),m(Yf,{children:[o(St,{type:"button",variant:"ghost",size:c,disabled:b,onClick:()=>g(!1),children:"Cancel"}),m(St,{type:"button",variant:i,size:c,disabled:b,onClick:()=>{w()},children:[b&&o(Fe,{className:"h-3.5 w-3.5 animate-spin"}),s??e]})]})]})})]})}function vy(e,t){const r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r)}function RE({trpc:e,deviceId:t,deviceName:r,size:n="sm",className:s}){const[a,i]=M(!1),[c,l]=M(!1),[u,d]=M(null),p=r.replace(/[^a-zA-Z0-9_.-]+/g,"_"),h=I(async N=>{i(!0),d(null),l(!1);try{const E=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!E)throw new Error("No snapshot available");const D=`data:${E.contentType};base64,${E.base64}`;if(N==="copy")try{await navigator.clipboard.writeText(D)}catch{throw new Error("Clipboard unavailable")}else{const C=E.contentType.includes("png")?"png":"jpg";vy(`${p}-${new Date().toISOString().replace(/[:.]/g,"-")}.${C}`,D)}l(!0),setTimeout(()=>l(!1),1500)}catch(E){d(E instanceof Error?E.message:String(E))}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]=M(null),[y,x]=M(!1),w=()=>{x(!1),v(setTimeout(()=>{x(!0),h("copy")},600))},k=()=>{b&&(clearTimeout(b),v(null)),y||h("download")},S=()=>{b&&(clearTimeout(b),v(null))};return m("button",{type:"button",title:"Click to download · long-press to copy",disabled:a,onPointerDown:w,onPointerUp:k,onPointerLeave:S,onPointerCancel:S,className:A("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(qt,{className:"h-3.5 w-3.5 text-success"}):o(Ro,{className:"h-3.5 w-3.5"}),"Snapshot"]})}function yy(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 _E({history:e,limit:t=5,latestIsFresh:r,className:n}){if(e.length===0)return null;const s=r?Hp:sn,a=e.slice(0,t);return m("div",{className:A("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:A("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:yy(i.timestamp)}),o("span",{className:"text-foreground-subtle font-mono text-[10px]",children:new Date(i.timestamp).toLocaleTimeString()})]},`${i.deviceId}-${i.timestamp}`))})]})}function IE({items:e,header:t,triggerClassName:r,title:n="More actions"}){const[s,a]=M(!1),i=e.filter(c=>!c.hidden);return i.length===0?null:m(em,{open:s,onOpenChange:a,children:[o(tm,{title:n,className:A("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(rm,{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:A("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:A("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 xy=[{value:"view",label:"View",icon:Zt,hint:"Read-only — queries + subscriptions"},{value:"create",label:"Create",icon:bf,hint:"Mutations that create or update"},{value:"delete",label:"Delete",icon:Xe,hint:"Destructive ops (delete/revoke/reset/…)"}],wy=["device","system"];function ky(){return{type:"capability",target:"",access:["view"]}}function Ny(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 Sy(e,t,r,n){let s;switch(e){case"addon":s=r;break;case"capability":s=n;break;case"category":s=wy.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 Cy(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 TE({value:e,onChange:t,clampToParent:r,emptyHint:n}){const{data:s}=Ng(),{data:a}=Kl({}),i=X(()=>(s??[]).map(b=>({value:b.manifest.id,label:b.manifest.id})).sort((b,v)=>b.label.localeCompare(v.label)),[s]),c=X(()=>[...Gc].sort().map(b=>({value:b,label:b})),[]),l=X(()=>(a??[]).map(b=>({value:String(b.id),label:`${b.name} (#${b.id} · ${b.addonId})`})).sort((b,v)=>b.label.localeCompare(v.label)),[a]),u=X(()=>r==null?null:Ny(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 w=[...v.access??y.access];return y.type==="device"?{type:"device",targets:[...v.targets??y.targets],access:w}:y.type==="category"?{type:"category",target:v.target??y.target,access:w}:y.type==="capability"?{type:"capability",target:v.target??y.target,access:w}:{type:"addon",target:v.target??y.target,access:w}}))},h=b=>{t(e.filter((v,y)=>y!==b))},g=()=>{t([...e,ky()])};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=Cy(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(My,{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," —"]}),Sy(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:xy.map(({value:x,label:w,icon:k,hint:S})=>{const N=b.access.includes(x),E=r!=null&&!y.includes(x)&&!N;return m("label",{title:E?`${S} — not granted by your scope`:S,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${N?"bg-primary/15 text-primary font-medium":"text-foreground-subtle hover:bg-foreground-subtle/10"} ${E?"opacity-40 cursor-not-allowed":""}`,children:[o("input",{type:"checkbox",checked:N,disabled:E,onChange:D=>{const C=new Set(b.access);D.target.checked?C.add(x):C.delete(x),p(v,{access:[...C]})},className:"sr-only"}),o(k,{className:"h-3 w-3"}),w]},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(Re,{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(Yt,{className:"h-3 w-3"}),"Add scope"]})]})}function My({value:e,choices:t,clampToParent:r,onChange:n}){const[s,a]=M(""),i=X(()=>{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(Re,{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 DE(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 Nc=ht("camstack:zone-editing",null);function LE({children:e}){const[t,r]=M(!1),[n,s]=M(null),[a,i]=M(null),[c,l]=M(null),u=I(w=>{r(w),w||(s(null),i(null),l(null))},[]),d=I(w=>{s(w)},[]),p=I(w=>{i(w)},[]),h=I(w=>{r(!0),i(null),s(w),l(null)},[]),g=I(()=>{r(!1),s(null),i(null),l(null)},[]),b=I(w=>{i(w.id),l(w)},[]),v=I(w=>{l(k=>k===null?k:{...k,...w})},[]),y=I(()=>{l(null)},[]),x=X(()=>({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(Nc.Provider,{value:x,children:e})}function OE(){return Pe(Nc)}var ia=500,Ey=800;function Br(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 Fr(e,t){return e?.id===t}function $E(e,t){const[r,n]=M(null),[s,a]=M(null),[i,c]=M(null),[l,u]=M("watching"),d=J(void 0),p=J(void 0),h=J(void 0);return Z(()=>{if(t===null)return;const g=Br(e,"detection.motion-analysis",b=>{const v=b;if(!Fr(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),ia))});return()=>{g?.unsubscribe(),d.current&&clearTimeout(d.current)}},[e,t]),Z(()=>{if(t===null)return;const g=Br(e,"detection.motion-zones-raw",b=>{const v=b;if(!Fr(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,w)=>x+w.changeScore,0)/y.zones.length:0}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>a(null),ia))});return()=>{g?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),Z(()=>{if(t===null)return;const g=Br(e,"detection.result",b=>{const v=b;if(!Fr(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),Ey))});return()=>{g?.unsubscribe(),h.current&&clearTimeout(h.current)}},[e,t]),Z(()=>{if(t===null)return;const g=Br(e,"detection.phase-transition",b=>{const v=b;Fr(v?.source,t)&&v.data?.to&&u(v.data.to)});return()=>{g?.unsubscribe()}},[e,t]),{motion:r,motionRaw:s,detection:i,phase:l}}function BE(e,t,r=5e3){const[n,s]=M([]);Z(()=>{if(t===null)return;let g=!1;const b=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(y=>{g||s(y)}).catch(()=>{})};b();const v=setInterval(b,r);return()=>{g=!0,clearInterval(v)}},[e,t,r]);const[a,i]=M(null);Z(()=>{if(t===null)return;let g=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(b=>{g||!b||i({phase:b.phase,detectionFps:b.actualFps,avgInferenceMs:b.avgInferenceTimeMs,droppedFrames:b.droppedFrames})}).catch(()=>{}),()=>{g=!0}},[e,t]),cn("pipeline.camera-metrics-snapshot",g=>{if(t===null)return;const b=g.data;b.deviceId!==t||!b.metrics||i({phase:b.metrics.phase,detectionFps:b.metrics.actualFps,avgInferenceMs:b.metrics.avgInferenceTimeMs,droppedFrames:b.metrics.droppedFrames})});const{streams:c,hasWebrtc:l}=X(()=>t===null||n.length===0?{streams:[],hasWebrtc:!1}:{streams:n.map(g=>({id:g.id,label:g.label,target:g.target,status:g.status,inputFps:g.inputFps,decodeFps:g.decodeFps,bitrateKbps:g.bitrateKbps})),hasWebrtc:!0},[t,n]),u=I(async()=>{if(e.turnProvider)try{return(await e.turnProvider.getTurnServers.query()).map(g=>({urls:typeof g.urls=="string"?g.urls:[...g.urls],...g.username!==void 0?{username:g.username}:{},...g.credential!==void 0?{credential:g.credential}:{}}))}catch{return}},[e]),d=I(async(g,b)=>{if(t===null)throw new Error("No device selected");const v=await e.webrtcSession.createSession.mutate({deviceId:t,target:g,hints:b}),y=await u();return{sessionId:v.sessionId,sdpOffer:v.sdpOffer,...y?{iceServers:y}:{}}},[e,t,u]),p=I(async(g,b)=>{if(t===null)throw new Error("No device selected");return e.webrtcSession.handleOffer.mutate({deviceId:t,target:g,sdpOffer:b})},[e,t]),h=I(async(g,b)=>{if(t===null)throw new Error("No device selected");await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:g,sdpAnswer:b})},[e,t]);return{streams:c,hasWebrtc:l,pipelineMetrics:a,createSession:d,handleOffer:p,getIceServers:u,addIceCandidate:I(async(g,b)=>{t!==null&&await e.webrtcSession.addIceCandidate.mutate({deviceId:t,sessionId:g,candidate:b.candidate??"",sdpMid:b.sdpMid??null,sdpMLineIndex:b.sdpMLineIndex??null}).catch(()=>{})},[e,t]),getIceCandidates:I(async g=>t===null?{candidates:[],done:!0}:e.webrtcSession.getIceCandidates.query({deviceId:t,sessionId:g}),[e,t]),sendAnswer:h,closeSession:I(async g=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:g}).catch(()=>{})},[e,t])}}function FE(e){const t=e?.deviceId??null,r=e?.historyLimit??20,n=ml("doorbell.onPressed",t!==null?i=>i.deviceId===t:void 0),[s,a]=M([]);return Z(()=>{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 zE(e){const t=et(),r=X(()=>e?JSON.stringify(e):"",[e]),[n,s]=M(()=>t.listDevices(e));return Z(()=>{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 GE(e){const t=et(),[r,n]=M(()=>e===null?null:t.getDevice(e));return Z(()=>{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 QE(e,t,r){const n=et();return pa({queryKey:e,queryFn:()=>t(n)(),...r})}function jE(e,t){const r=et();return Pc({mutationFn:n=>e(r)(n),...t})}function UE(e,t){const r=et(),n=xr(),[s,a]=M(r.connectionVersion);Z(()=>r.subscribeConnectionEvents((l,u)=>{l==="connected"&&a(u)}),[r]);const i=t.join("|"),c=JSON.stringify(e);Z(()=>{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{mE as AddonGlobalSettingsForm,L0 as AgentStepEditor,Z0 as AppShell,kE as AudioClassificationList,wE as AudioLevelWaveform,xE as AudioWaveform,Ug as AutotrackSection,s0 as BTN_COMPACT,i0 as BTN_COMPACT_DANGER,a0 as BTN_COMPACT_PRIMARY,l0 as BTN_COMPACT_WARNING,Qt as Badge,oh as BatteryBadge,sl as BottomSheet,R0 as Breadcrumb,St as Button,d0 as CHIP_ACTIVE,u0 as CHIP_BASE,p0 as CHIP_INACTIVE,Ar as CLASS_COLORS,fv as CameraStreamPlayer,Wi as Card,Vf as Checkbox,q0 as CodeBlock,jf as CollapsibleCard,ev as ConfigFormBuilder,kr as ConfigFormField,Oo as ConfigSchemaField,PE as ConfirmActionButton,H0 as ConfirmDialogProvider,Dv as CopyButton,ux as CustomFieldRenderersProvider,rx as DEFAULT_COLOR,_0 as DataTable,nx as DetectionCanvas,nv as DetectionOverlay,ox as DetectionResultTree,xg as DevShell,AE as DeviceActivityPanel,Y0 as DeviceCard,dx as DeviceContextProvider,yE as DeviceExportPanel,X0 as DeviceGrid,oo as DeviceItem,Nh as DeviceList,qf as Dialog,Xi as DialogContent,Jf as DialogDescription,Yf as DialogFooter,Zf as DialogHeader,Xf as DialogTitle,g0 as DialogTrigger,EE as DiscoveryPanel,_E as DoorbellRecentPanel,b0 as Dropdown,y0 as DropdownContent,x0 as DropdownItem,v0 as DropdownTrigger,km as EmptyState,Sm as ErrorBox,yc as EventStream,K0 as FilterBar,ME as FloatingEventStream,CE as FloatingLogStream,P0 as FloatingPanel,j0 as FormField,Ky as GRID_GAP,Xy as GRID_PAIRED,Yy as GRID_QUICK_STATS,pb as HOST_WIDGETS,c0 as INPUT_COMPACT,Vi as IconButton,ax as ImageSelector,ix as InferenceConfigSelector,to as Input,IE as KebabMenu,W0 as KeyValueList,Zy as LIST_ROW,qi as Label,vc as LogStream,hg as LoginForm,nc as MaskShapeCanvas,nm as MobileDrawer,ab as MotionZonesSettings,Ab as NodeMultiSelectField,F0 as NodePicker,Eb as NodeSelectField,os as PHASE_CONFIG,Sl as PTZOverlay,U0 as PageHeader,SE as PhaseIcon,tx as PipelineBuilder,ex as PipelineRuntimeSelector,Sn as PipelineStep,O0 as PipelineTreeMatrix,dE as PlayerOverlaysProvider,em as Popover,rm as PopoverContent,tm as PopoverTrigger,G0 as ProviderBadge,Qg as PtzPanel,Iv as QrCode,NE as ResponseLog,Wy as SECTION_BODY,Hy as SECTION_CARD,Vy as SECTION_HEADER,Jy as SPLIT_PANEL_OUTER,e0 as SPLIT_PANEL_SIDE,qy as STACK_GAP,TE as ScopePicker,ul as ScrollArea,en as Select,wm as SemanticBadge,Ki as Separator,As as Sidebar,Es as SidebarItem,Hf as Skeleton,I0 as SlideOverPanel,RE as SnapshotButton,V0 as StatCard,uy as StateValuesStream,z0 as StatusBadge,sx as StepTimings,T0 as StepTreeMaster,gE as StreamBrokerSelector,hE as StreamPanel,Wf as Switch,bm as SystemProvider,r0 as TEXT_FIELD_LABEL,ot as TEXT_HINT,o0 as TEXT_METRIC,t0 as TEXT_SECTION_LABEL,n0 as TEXT_VALUE,C0 as Tabs,A0 as TabsContent,M0 as TabsList,E0 as TabsTrigger,Yo as ThemeProvider,w0 as Tooltip,N0 as TooltipContent,k0 as TooltipTrigger,Q0 as VersionBadge,lE as WidgetRegistryProvider,fb as WidgetSlot,LE as ZoneEditingProvider,D0 as buildStepTreeFromSchema,A as cn,ht as createSharedContext,jy as createTheme,Hc as darkColors,qo as defaultTheme,J0 as deriveDeviceKind,Rp as ensureMfHostInit,je as getClassColor,ja as getPhaseVisual,Zr as isAbsentProvider,Yb as isFieldVisible,Vc as lightColors,Yl as loadRemoteBundle,f0 as mirror,cx as mountAddonPage,m0 as providerIcons,h0 as statusIcons,Uy as themeToCss,f as trpc,fx as useAccessoriesGetStatus,mx as useAddonPagesListPages,Zx as useAddonSettingsGetDeviceSettings,qx as useAddonSettingsGetGlobalSettings,Yx as useAddonSettingsUpdateDeviceSettings,Kx as useAddonSettingsUpdateGlobalSettings,Sg as useAddonWidgetsListWidgets,Hx as useAddonsApplyAutoUpdateToAll,Ox as useAddonsCancelBulkUpdate,Vx as useAddonsCustom,Ex as useAddonsForceRefresh,jx as useAddonsGetAddonAutoUpdate,Gx as useAddonsGetAutoUpdateSettings,Lx as useAddonsGetBulkUpdateState,Px as useAddonsGetLastRestart,hx as useAddonsGetLogs,Bx as useAddonsGetVersions,vx as useAddonsInstallFromWorkspace,bx as useAddonsInstallPackage,yx as useAddonsIsWorkspaceAvailable,Ng as useAddonsList,$x as useAddonsListActiveBulkUpdates,_x as useAddonsListCapabilityProviders,Rx as useAddonsListFrameworkPackages,gx as useAddonsListPackages,Sx as useAddonsListUpdates,xx as useAddonsListWorkspacePackages,Wx as useAddonsOnAddonLogs,kx as useAddonsReloadPackages,Fx as useAddonsRestartAddon,Ax as useAddonsRestartServer,zx as useAddonsRetryLoad,Mx as useAddonsRollbackPackage,Nx as useAddonsSearchAvailable,Ux as useAddonsSetAddonAutoUpdate,Qx as useAddonsSetAutoUpdateSettings,Ix as useAddonsSetCapabilityProviderEnabled,Dx as useAddonsStartBulkUpdate,wx as useAddonsUninstallPackage,Tx as useAddonsUpdateFrameworkPackage,Cx as useAddonsUpdatePackage,o1 as useAlertsDismiss,Xx as useAlertsEmit,t1 as useAlertsGetUnreadCount,e1 as useAlertsList,n1 as useAlertsMarkAllRead,r1 as useAlertsMarkRead,Jx as useAlertsUpdate,uE as useAllWidgets,l1 as useAudioAnalysisApplyDeviceSettingsPatch,i1 as useAudioAnalysisGetDeviceLiveContribution,a1 as useAudioAnalysisGetDeviceSettingsContribution,s1 as useAudioAnalysisResolveDeviceSettings,c1 as useAudioAnalyzerAnalyseChunk,u1 as useAudioAnalyzerClassify,p1 as useAudioAnalyzerDispose,d1 as useAudioAnalyzerIsReady,f1 as useAudioAnalyzerReprobeAudioEngine,h1 as useAudioCodecCanHandle,v1 as useAudioCodecCloseSession,g1 as useAudioCodecCreateDecodeSession,b1 as useAudioCodecCreateEncodeSession,N1 as useAudioCodecFlushEncode,S1 as useAudioCodecListActiveSessions,m1 as useAudioCodecListSupportedCodecs,k1 as useAudioCodecPullEncoded,x1 as useAudioCodecPullPcm,y1 as useAudioCodecPushEncodedFrame,w1 as useAudioCodecPushPcm,C1 as useAudioMetricsGetCurrentSnapshot,M1 as useAudioMetricsGetHistory,T1 as useBackupDelete,_1 as useBackupGetEntries,P1 as useBackupList,D1 as useBackupListArchives,E1 as useBackupListDestinations,R1 as useBackupListLocations,O1 as useBackupPreviewSchedule,I1 as useBackupRestore,A1 as useBackupTrigger,L1 as useBackupUpsertDestinationPolicy,$1 as useBatteryGetStatus,F1 as useBrightnessGetStatus,B1 as useBrightnessSetBrightness,z1 as useCameraCredentialsGetCredentials,G1 as useCameraCredentialsGetStatus,U1 as useCameraPipelineConfigApplyDeviceSettingsPatch,j1 as useCameraPipelineConfigGetDeviceLiveContribution,Q1 as useCameraPipelineConfigGetDeviceSettingsContribution,V1 as useCameraStreamsGetBrokerStreams,H1 as useCameraStreamsGetCameraStreams,Cg as useCameraStreamsGetRtspEntries,Bo as useClusterNodes,un as useConfirm,wg as useCustomFieldRenderer,lh as useDebouncedString,K1 as useDecoderCreateSession,Z1 as useDecoderDestroySession,tw as useDecoderGetFrame,q1 as useDecoderGetInfo,rw as useDecoderGetShmStats,ow as useDecoderGetStats,sw as useDecoderListActiveSessions,X1 as useDecoderOpenStream,J1 as useDecoderPullFrames,ew as useDecoderPullHandles,Y1 as useDecoderPushPacket,aw as useDecoderReprobeHwaccel,W1 as useDecoderSupportsCodec,nw as useDecoderUpdateConfig,cw as useDetectionPipelineApplyDeviceSettingsPatch,lw as useDetectionPipelineGetDeviceLiveContribution,iw as useDetectionPipelineGetDeviceSettingsContribution,lx as useDevShell,GE as useDevice,jg as useDeviceAutotrack,eh as useDeviceBattery,wr as useDeviceCapability,$E as useDeviceDetections,pw as useDeviceDiscoveryAdoptDevice,mw as useDeviceDiscoveryGetStatus,uw as useDeviceDiscoveryListDiscovered,dw as useDeviceDiscoveryRefreshDiscovery,fw as useDeviceDiscoveryReleaseDevice,bw as useDeviceExportApplyDeviceSettingsPatch,Pg as useDeviceExportExposeDevice,gw as useDeviceExportGetDeviceLiveContribution,hw as useDeviceExportGetDeviceSettingsContribution,Mg as useDeviceExportGetStatus,Ag as useDeviceExportListExposedDevices,Eg as useDeviceExportListSupportedDeviceKinds,Rg as useDeviceExportUnexposeDevice,kg as useDeviceId,Pw as useDeviceManagerAddLocation,rk as useDeviceManagerAdoptDevice,vw as useDeviceManagerAllocateDeviceId,ok as useDeviceManagerCreateDevice,zw as useDeviceManagerDisable,tk as useDeviceManagerDiscoverDevices,Fw as useDeviceManagerEnable,Vw as useDeviceManagerGetAllBindings,Hw as useDeviceManagerGetBindings,Dw as useDeviceManagerGetChildren,Ow as useDeviceManagerGetConfigSchema,nk as useDeviceManagerGetCreationSchema,Tw as useDeviceManagerGetDevice,Xw as useDeviceManagerGetDeviceAggregate,Yw as useDeviceManagerGetDeviceLiveInfoAggregate,Zw as useDeviceManagerGetDeviceSettingsAggregate,ik as useDeviceManagerGetDeviceStatusAggregate,$w as useDeviceManagerGetSettingsSchema,Qw as useDeviceManagerGetStreamProfileMap,Lw as useDeviceManagerGetStreamSources,Kl as useDeviceManagerListAll,Kw as useDeviceManagerListBindableCapsForDeviceType,Aw as useDeviceManagerListLocations,Iw as useDeviceManagerListPersistedByAddon,qw as useDeviceManagerListWrappersForCap,kw as useDeviceManagerLoadConfig,Sw as useDeviceManagerLoadMeta,Nw as useDeviceManagerLoadRuntimeState,ww as useDeviceManagerPersistConfig,Uw as useDeviceManagerProbeStreams,yw as useDeviceManagerRegisterDevice,Gw as useDeviceManagerRemove,xw as useDeviceManagerRemoveDevice,Rw as useDeviceManagerRemoveLocation,_w as useDeviceManagerSetDisabled,Mw as useDeviceManagerSetLocation,Ew as useDeviceManagerSetMetadata,Cw as useDeviceManagerSetName,jw as useDeviceManagerSetStreamProfileMap,Ww as useDeviceManagerSetWrapperActive,sk as useDeviceManagerTestCreationField,ak as useDeviceManagerTestField,Bw as useDeviceManagerUpdateConfig,Jw as useDeviceManagerUpdateDeviceField,ek as useDeviceManagerUpdateDeviceFieldsBatch,ck as useDeviceOpsGetConfigEntries,pk as useDeviceOpsGetSettingsSchema,lk as useDeviceOpsGetStreamSources,dk as useDeviceOpsRemoveDevice,uk as useDeviceOpsSetConfig,yk as useDeviceProviderAdoptDiscoveredDevice,kk as useDeviceProviderCreateDevice,vk as useDeviceProviderDiscoverDevices,wk as useDeviceProviderGetChildCreationSchema,gk as useDeviceProviderGetDevices,hk as useDeviceProviderGetStatus,fk as useDeviceProviderStart,mk as useDeviceProviderStop,bk as useDeviceProviderSupportsDiscovery,xk as useDeviceProviderSupportsManualCreation,Nk as useDeviceProviderTestCreationField,Pt as useDeviceProxy,px as useDeviceSnapshot,th as useDeviceSnapshotImage,Em as useDeviceState,Mk as useDeviceStateGetAllSnapshots,Ck as useDeviceStateGetCapSlice,Sk as useDeviceStateGetSnapshot,Ek as useDeviceStateSetCapSlice,gl as useDeviceStateSlice,Ak as useDeviceStatusGetStatus,BE as useDeviceWebrtc,zE as useDevices,FE as useDoorbellEvents,Pk as useDoorbellGetStatus,UE as useEventInvalidation,ml as useEventStreamLatest,B0 as useEventStreamMap,Ik as useEventsGetEventClipUrl,_k as useEventsGetEventThumbnail,Rk as useEventsGetEvents,Tk as useFeatureProbeGetStatus,$k as useIntegrationsCreate,Fk as useIntegrationsDelete,Lk as useIntegrationsGet,Qk as useIntegrationsGetAvailableTypes,Ok as useIntegrationsGetByAddonId,zk as useIntegrationsGetSettings,Dk as useIntegrationsList,Gk as useIntegrationsSetSettings,jk as useIntegrationsTestConnection,Bk as useIntegrationsUpdate,Kk as useIntercomEndTalkSession,Zk as useIntercomGetStatus,Hk as useIntercomHandleAnswer,qk as useIntercomPushTalkPcm,Uk as useIntercomStartSession,Wk as useIntercomStartTalkSession,Vk as useIntercomStopSession,S0 as useIsMidWidth,ln as useIsMobile,cr as useLiveBuffer,cn as useLiveEvent,e2 as useLocalNetworkGetAllowedAddresses,Jk as useLocalNetworkGetConnectionEndpoints,Xk as useLocalNetworkGetPreferred,Yk as useLocalNetworkList,r2 as useLocalNetworkResetAllowlistToBestMatch,t2 as useLocalNetworkSetAllowedAddresses,n2 as useMeshNetworkGetStatus,o2 as useMeshNetworkJoin,a2 as useMeshNetworkLeave,l2 as useMeshNetworkListPeers,i2 as useMeshNetworkLogout,s2 as useMeshNetworkStartLogin,c2 as useMeshNetworkTestConnection,u2 as useMetricsProviderCollectSnapshot,v2 as useMetricsProviderGetAddonStats,d2 as useMetricsProviderGetCached,h2 as useMetricsProviderGetCpuTemperature,p2 as useMetricsProviderGetCurrent,f2 as useMetricsProviderGetDiskSpace,m2 as useMetricsProviderGetGpuInfo,g2 as useMetricsProviderGetProcessStats,x2 as useMetricsProviderKillProcess,b2 as useMetricsProviderListAddonInstances,y2 as useMetricsProviderListNodeProcesses,N2 as useMotionDetectionAnalyze,A2 as useMotionDetectionApplyDeviceSettingsPatch,E2 as useMotionDetectionGetDeviceLiveContribution,M2 as useMotionDetectionGetDeviceSettingsContribution,S2 as useMotionDetectionRemoveCamera,C2 as useMotionDetectionReset,k2 as useMotionGetStatus,w2 as useMotionIsDetected,R2 as useMotionTriggerGetStatus,P2 as useMotionTriggerSetMotionTrigger,_2 as useMotionZonesGetOptions,T2 as useMotionZonesGetStatus,I2 as useMotionZonesSetZone,O2 as useMqttBrokerAddBroker,L2 as useMqttBrokerGetBrokerConfig,G2 as useMqttBrokerGetStatus,D2 as useMqttBrokerListBrokers,$2 as useMqttBrokerRemoveBroker,F2 as useMqttBrokerStartEmbeddedBroker,z2 as useMqttBrokerStopEmbeddedBroker,B2 as useMqttBrokerTestConnection,j2 as useNativeObjectDetectionGetStatus,Q2 as useNativeObjectDetectionSetEnabled,V2 as useNetworkAccessGetEndpoint,W2 as useNetworkAccessGetStatus,q2 as useNetworkAccessListEndpoints,U2 as useNetworkAccessStart,H2 as useNetworkAccessStop,Z2 as useNetworkQualityGetAllStats,K2 as useNetworkQualityGetDeviceStats,Y2 as useNetworkQualityReportClientStats,aN as useNodesClusterAddonStatus,J2 as useNodesDeployAddon,uN as useNodesExecuteQuery,iN as useNodesGetCapUsageGraph,lN as useNodesGetNodeAddons,sN as useNodesRenameNode,tN as useNodesRestartAddon,nN as useNodesRestartNode,rN as useNodesRestartProcess,cN as useNodesSetProcessLogLevel,oN as useNodesShutdownNode,X2 as useNodesTopology,eN as useNodesUndeployAddon,dN as useNotificationOutputSend,pN as useNotificationOutputSendTest,$0 as useOptionalSystem,Xl as useOptionalWidgetRegistry,mN as useOsdGetStatus,fN as useOsdSetOverlay,Nl as usePTZ,MN as usePipelineAnalyticsApplyDeviceSettingsPatch,vN as usePipelineAnalyticsClearTracks,hN as usePipelineAnalyticsGetActiveTracks,wN as usePipelineAnalyticsGetAudioEvents,CN as usePipelineAnalyticsGetDeviceLiveContribution,SN as usePipelineAnalyticsGetDeviceSettingsContribution,kN as usePipelineAnalyticsGetEventMedia,yN as usePipelineAnalyticsGetMotionEvents,xN as usePipelineAnalyticsGetObjectEvents,gN as usePipelineAnalyticsGetTrack,NN as usePipelineAnalyticsGetTrackMedia,bN as usePipelineAnalyticsListTracks,qN as usePipelineExecutorCacheFrameInPool,UN as usePipelineExecutorDeleteModel,zN as usePipelineExecutorDeleteTemplate,HN as usePipelineExecutorDetect,jN as usePipelineExecutorDownloadModel,QN as usePipelineExecutorGetAddonModels,sS as usePipelineExecutorGetAudioCapabilities,EN as usePipelineExecutorGetAvailableEngines,GN as usePipelineExecutorGetCapabilities,PN as usePipelineExecutorGetDefaultSteps,iS as usePipelineExecutorGetDetectionConfigSchema,YN as usePipelineExecutorGetEffectiveTuning,LN as usePipelineExecutorGetGlobalPipelineConfig,DN as usePipelineExecutorGetGlobalSteps,ON as usePipelineExecutorGetOrchestratorConfigSchema,oS as usePipelineExecutorGetReferenceAudio,nS as usePipelineExecutorGetReferenceAudioFiles,rS as usePipelineExecutorGetReferenceImage,TN as usePipelineExecutorGetSchema,AN as usePipelineExecutorGetSelectedEngine,_N as usePipelineExecutorGetVideoPipelineSteps,KN as usePipelineExecutorInferCached,eS as usePipelineExecutorKillEngine,XN as usePipelineExecutorListLoadedEngines,tS as usePipelineExecutorListReferenceImages,$N as usePipelineExecutorListTemplates,RN as usePipelineExecutorReprobeEngine,aS as usePipelineExecutorRunAudioTest,VN as usePipelineExecutorRunPipeline,WN as usePipelineExecutorRunPipelineBatch,BN as usePipelineExecutorSaveTemplate,IN as usePipelineExecutorSetVideoPipelineSteps,JN as usePipelineExecutorSpinEngine,ZN as usePipelineExecutorUncacheFrame,FN as usePipelineExecutorUpdateTemplate,jS as usePipelineOrchestratorApplyDeviceSettingsPatch,wS as usePipelineOrchestratorAssignAudio,vS as usePipelineOrchestratorAssignDecoder,lS as usePipelineOrchestratorAssignPipeline,zS as usePipelineOrchestratorDeleteTemplate,fS as usePipelineOrchestratorGetAgentLoad,ES as usePipelineOrchestratorGetAgentSettings,NS as usePipelineOrchestratorGetAudioAssignment,CS as usePipelineOrchestratorGetAudioAssignments,SS as usePipelineOrchestratorGetAudioNodeLoad,hS as usePipelineOrchestratorGetCameraMetrics,_S as usePipelineOrchestratorGetCameraSettings,TS as usePipelineOrchestratorGetCameraStepOverrides,gS as usePipelineOrchestratorGetCapabilityBindings,MS as usePipelineOrchestratorGetDecoderAssignment,xS as usePipelineOrchestratorGetDecoderAssignments,QS as usePipelineOrchestratorGetDeviceLiveContribution,GS as usePipelineOrchestratorGetDeviceSettingsContribution,mS as usePipelineOrchestratorGetGlobalMetrics,pS as usePipelineOrchestratorGetPipelineAssignment,dS as usePipelineOrchestratorGetPipelineAssignments,AS as usePipelineOrchestratorListAgentSettings,$S as usePipelineOrchestratorListTemplates,uS as usePipelineOrchestratorRebalance,RS as usePipelineOrchestratorRemoveAgentSettings,OS as usePipelineOrchestratorResolvePipeline,BS as usePipelineOrchestratorSaveTemplate,PS as usePipelineOrchestratorSetAgentAddonDefaults,LS as usePipelineOrchestratorSetCameraPipelineForAgent,DS as usePipelineOrchestratorSetCameraStepOverride,IS as usePipelineOrchestratorSetCameraStepToggle,bS as usePipelineOrchestratorSetCapabilityBinding,kS as usePipelineOrchestratorUnassignAudio,yS as usePipelineOrchestratorUnassignDecoder,cS as usePipelineOrchestratorUnassignPipeline,FS as usePipelineOrchestratorUpdateTemplate,US as usePipelineRunnerAttachCamera,HS as usePipelineRunnerDetachCamera,ZS as usePipelineRunnerGetAllCameraMetrics,KS as usePipelineRunnerGetCameraMetrics,YS as usePipelineRunnerGetLocalCameras,WS as usePipelineRunnerGetLocalLoad,qS as usePipelineRunnerGetLocalMetrics,VS as usePipelineRunnerReportMotion,XS as usePlatformProbeGetCapabilities,JS as usePlatformProbeGetHardware,rC as usePlatformProbeGetHardwareEncoders,nC as usePlatformProbeRefreshHardwareEncoders,tC as usePlatformProbeResolveHwAccel,eC as usePlatformProbeResolveInferenceConfig,Jl as usePlayerOverlayLayer,pE as usePlayerOverlayLayers,fE as usePlayerToolbarButton,Hg as usePlayerToolbarButtons,oC as usePrivacyMaskGetOptions,aC as usePrivacyMaskGetStatus,sC as usePrivacyMaskSetMask,yC as usePtzAutotrackGetSettings,_g as usePtzAutotrackGetStatus,Ig as usePtzAutotrackSetEnabled,Tg as usePtzAutotrackSetSettings,lC as usePtzContinuousMove,fC as usePtzDeletePreset,mC as usePtzGetOptions,gC as usePtzGetPosition,uC as usePtzGetPresets,vC as usePtzGetStatus,hC as usePtzGoHome,dC as usePtzGoToPreset,iC as usePtzMove,pC as usePtzSavePreset,bC as usePtzSetAutofocus,cC as usePtzStop,xC as useRebootReboot,MC as useRecordingEngineDisable,CC as useRecordingEngineEnable,DC as useRecordingEngineEstimateGlobalStorage,TC as useRecordingEngineEstimateStorage,IC as useRecordingEngineGetAvailability,EC as useRecordingEngineGetConfig,GC as useRecordingEngineGetMotionStats,PC as useRecordingEngineGetPlaylist,$C as useRecordingEngineGetPolicy,BC as useRecordingEngineGetPolicyStatus,FC as useRecordingEngineGetRetentionConfig,_C as useRecordingEngineGetSegments,SC as useRecordingEngineGetStatus,LC as useRecordingEngineGetStorageUsage,RC as useRecordingEngineGetThumbnail,OC as useRecordingEngineSetPolicy,AC as useRecordingEngineUpdateConfig,zC as useRecordingEngineUpdateRetentionConfig,kC as useRecordingGetPlaybackUrl,wC as useRecordingGetSegments,NC as useRecordingGetThumbnailAt,Fg as useRemoteComponent,qC as useSettingsStoreCount,ZC as useSettingsStoreDeclareCollection,WC as useSettingsStoreDelete,QC as useSettingsStoreGet,HC as useSettingsStoreInsert,KC as useSettingsStoreIsEmpty,UC as useSettingsStoreQuery,jC as useSettingsStoreSet,VC as useSettingsStoreUpdate,r5 as useSnapshotApplyDeviceSettingsPatch,t5 as useSnapshotGetDeviceLiveContribution,e5 as useSnapshotGetDeviceSettingsContribution,YC as useSnapshotGetSnapshot,JC as useSnapshotGetStatus,XC as useSnapshotInvalidateCache,o5 as useSnapshotProviderGetSnapshot,n5 as useSnapshotProviderSupportsDevice,h5 as useStorageAbortUpload,g5 as useStorageBeginDownload,p5 as useStorageBeginUpload,u5 as useStorageDelete,k5 as useStorageDeleteLocation,v5 as useStorageEndDownload,l5 as useStorageExists,m5 as useStorageFinalizeUpload,d5 as useStorageGetAvailableSpace,x5 as useStorageGetDefaultLocation,c5 as useStorageList,y5 as useStorageListLocations,S5 as useStorageListProviders,i5 as useStorageRead,b5 as useStorageReadChunk,s5 as useStorageResolve,C5 as useStorageTestConfig,N5 as useStorageTestLocation,w5 as useStorageUpsertLocation,a5 as useStorageWrite,f5 as useStorageWriteChunk,tM as useStreamBrokerApplyDeviceSettingsPatch,A5 as useStreamBrokerAssignProfile,q5 as useStreamBrokerGetAllRtspEntries,I5 as useStreamBrokerGetBrokerStats,eM as useStreamBrokerGetDeviceLiveContribution,J5 as useStreamBrokerGetDeviceSettingsContribution,V5 as useStreamBrokerGetPreBufferInfo,K5 as useStreamBrokerGetRtspEntry,W5 as useStreamBrokerGetRtspPort,O5 as useStreamBrokerGetStreamUrl,$5 as useStreamBrokerGetStreamWithCodec,X5 as useStreamBrokerIsRtspEnabled,D5 as useStreamBrokerKillClient,R5 as useStreamBrokerListAllCameraStreams,_5 as useStreamBrokerListAllProfileSlots,T5 as useStreamBrokerListClients,M5 as useStreamBrokerPublishCameraStream,z5 as useStreamBrokerPullAudioChunks,j5 as useStreamBrokerPullFrameHandles,Z5 as useStreamBrokerRegenerateRtspToken,B5 as useStreamBrokerReleaseStreamWithCodec,L5 as useStreamBrokerRestartProfile,E5 as useStreamBrokerRetractCameraStream,H5 as useStreamBrokerSetPreBufferDuration,Y5 as useStreamBrokerSetRtspEnabled,F5 as useStreamBrokerSubscribeAudioChunks,Q5 as useStreamBrokerSubscribeFrames,P5 as useStreamBrokerUnassignProfile,G5 as useStreamBrokerUnsubscribeAudioChunks,U5 as useStreamBrokerUnsubscribeFrames,rM as useStreamCatalogGetCatalog,sM as useStreamParamsGetConfigSchema,nM as useStreamParamsGetOptions,aM as useStreamParamsGetStatus,oM as useStreamParamsSetProfile,lM as useSwitchGetStatus,iM as useSwitchSetState,et as useSystem,dM as useSystemFeatureFlags,hM as useSystemForceRetentionCleanup,fM as useSystemGetRetentionConfig,uM as useSystemHealth,cM as useSystemInfo,jE as useSystemMutation,pM as useSystemNetworkAddresses,QE as useSystemQuery,mM as useSystemSetRetentionConfig,Xc as useThemeMode,gM as useToastOnToast,bM as useTurnProviderGetTurnServers,DM as useUserManagementConfirmTotp,MM as useUserManagementCreateApiKey,PM as useUserManagementCreateScopedToken,yM as useUserManagementCreateUser,wM as useUserManagementDeleteUser,LM as useUserManagementDisableTotp,OM as useUserManagementGetTotpStatus,CM as useUserManagementListApiKeys,QM as useUserManagementListOauthSessions,IM as useUserManagementListScopedTokens,vM as useUserManagementListUsers,FM as useUserManagementOauthExchangeCode,BM as useUserManagementOauthIssueCode,zM as useUserManagementOauthRefresh,GM as useUserManagementOauthVerifyAccessToken,kM as useUserManagementResetPassword,EM as useUserManagementRevokeApiKey,jM as useUserManagementRevokeOauthSession,RM as useUserManagementRevokeScopedToken,NM as useUserManagementSetUserScopes,TM as useUserManagementSetupTotp,xM as useUserManagementUpdateUser,AM as useUserManagementValidateApiKey,SM as useUserManagementValidateCredentials,_M as useUserManagementValidateScopedToken,$M as useUserManagementVerifyTotp,qM as useWebrtcSessionAddIceCandidate,ZM as useWebrtcSessionCloseSession,HM as useWebrtcSessionCreateSession,KM as useWebrtcSessionGetIceCandidates,WM as useWebrtcSessionHandleAnswer,VM as useWebrtcSessionHandleOffer,YM as useWebrtcSessionHasAdaptiveBitrate,UM as useWebrtcSessionListStreams,cE as useWidget,Bg as useWidgetMetadata,Go as useWidgetRegistry,eE as useZoneAnalyticsGetCameraHistory,XM as useZoneAnalyticsGetCurrentSnapshot,tE as useZoneAnalyticsGetUnzonedHistory,JM as useZoneAnalyticsGetZoneHistory,OE as useZoneEditing,rE as useZoneRulesListRules,nE as useZoneRulesSetRules,sE as useZonesAddZone,oE as useZonesListZones,aE as useZonesRemoveZone,iE as useZonesUpdateZone,DE as validateScopes};